For this example, the benefit is to see how the loop works. In fact, for any beginning programming book, the benefit of almost everything will be just to learn and understand techniques. You're not going to write a lot of production-quality code that is truly useful for real business situations until you finish the beginning book and start working on larger and more confusing projects. The examples in beginner's books usually focus on a single concept at a time and "real-world" project often require that you use lots of different techniques all at once. But it's very hard to learn by studying those kinds of projects.
I often write values into the Output window with Console.WriteLine to see what values my program is using. You can see the values by setting breakpoints but it's often easier to look at many values all at once in the OutputWindow.
For example,. I was recently trying to draw a graph showing several hundred data points and some were wrong. I could step through the code but I would need to step through hundreds of values to find the ones that were messed up. Instead I wrote their values into the Output window. Then I could look in the window to see where they went wrong more easily. That still didn't solve the problem but it helped me figure out where the values were getting messed up.
|