Wrox Programmer Forums
|
BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer
This is the forum to discuss the Wrox book Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer by Rod Stephens; ISBN: 9780470596906
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2013, 10:09 PM
Authorized User
 
Join Date: May 2013
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Lesson 19, FOR loops

What is this supposed to do? Open a Command Prompt window?

(top of page 230)


Code:
Console.WriteLine(string.Format("{0} : {1}", i , iSquared));
 
Old June 16th, 2013, 11:59 PM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

That writes output into the Output window (aka the Console window). It's a quick way to display output without messing up the user interface.

If you can't find it, open the Debug menu's Windows submenu and select Output.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
 
Old June 17th, 2013, 12:29 PM
Authorized User
 
Join Date: May 2013
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'll try it.

What would be the practical application of doing this? Just as a test to see how the code works?
 
Old June 17th, 2013, 12:41 PM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

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.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Lesson 19 Exercise 4 mpthemaster BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 3 June 11th, 2011 08:54 PM
break for-each loops, or limit amount of loops warhero XSLT 2 July 4th, 2007 02:18 AM
Two Loops iloveoatmeal Classic ASP Basics 5 September 26th, 2005 09:59 AM
While loops and For loops in XSLT spencer.clark XSLT 1 August 5th, 2005 09:50 AM
loops Hudson40 Access VBA 1 February 4th, 2005 12:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.