I'm fairly certain that by law it is required for every programming book to provide the famous “Hello World” example. So, rather than face potential criminal charges, a walkthrough for creating a Console C# “Hello World” application follows.
Begin by staring Visual Studio .NET and selecting File, New Project. Next, select a C# console application and name it Hello World as shown in Figure 2.3.
Visual Studio .NET will create a default source file, Class1.cs, and provide some basic boilerplate code as shown in Listing 2.4.
Replace lines 16 though 18 with the following line of code:
Console.WriteLine( "Hello World" );
The Main method should now look like Listing 2.5.
1: static void Main(string[] args) 2: { 3: Console.WriteLine( "Hello World" ); 4: } |
The Console.WriteLine method will print the string Hello World to a console window. Figure 2.3 shows the results from executing the code. To execute the code, select Debug, Start Without Debugging or simply press Ctrl+F5 to launch the application.
3.143.5.15