Professional Documents
Culture Documents
Username: Kyle Daly Book: Learning C# 3.0. No part of any chapter or book may be reproduced or transmitted in any form by any means without the prior written permission for reprints and excerpts from the publisher of the book or chapter. Redistribution or other use that violates the fair use privilege under U.S. copyright laws (see 17 USC107) or that otherwise violates these Terms of Service is strictly prohibited. Violators will be prosecuted to the full extent of U.S. Federal and Massachusetts laws.
1 of 3
5/9/2012 6:24 PM
http://computersociety.safaribooksonline.com/print?xmlid=97805961550...
2 of 3
5/9/2012 6:24 PM
http://computersociety.safaribooksonline.com/print?xmlid=97805961550...
Solution to Exercise 1-1. Write an application that emits the words "What a great book!" to the console window. Hint: open Visual Studio, create a console application, and, if you get stuck, consider copying or modifying the code shown in the chapter. Remember, these exercises are for your own edification, no one is grading them, and making mistakes is an opportunity to explore and learn morethis is true in just about everything except nuclear physics. So, Don't Panic! To accomplish this exercise, you simply need to follow the same steps that you did to create Hello World in the chapter. Create a new console application from the Start Page, and give it whatever name you like, although "Exercise 1-1" is a reasonable name. When Visual Studio creates a code skeleton for you, click inside the Main( ) method and insert the following line:
Console.WriteLine("What a great book!");
Notice that we didn't use the System namespace in this line, because the using statement takes care of that. The exact code you use may vary somewhat, depending on what you chose to name your namespace and your class, and how you phrased your string, but one solution appears in Example A-1.
namespace Exercise_1_1 { class Program { static void Main(string[] args) { Console.WriteLine("What a great book!"); } } }
3 of 3
5/9/2012 6:24 PM