This sample shows several versions of a Hello World program in C#.
Security Note |
---|
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended. |
To build and run the Hello World samples within Visual Studio
Open the solution (HelloWorld.sln).
In Solution Explorer, right-click the HelloWorld1 project and click Set as StartUp Project.
From the Debug menu, click Start Without Debugging.
Press any key to close HelloWorld1.
In Solution Explorer, right-click the HelloWorld2 project and click Set as StartUp Project.
From the Debug menu, click Start Without Debugging.
Press any key to close HelloWorld2.
In Solution Explorer, right-click the HelloWorld3 project and click Set as StartUp Project.
In Solution Explorer, right-click the HelloWorld3 project and click Properties.
Open the Configuration Properties folder, and click Debug.
In the Command Line Arguments property, type "A B C D" and click OK.
From the Debug menu, click Start Without Debugging.
Press any key to close HelloWorld3.
In Solution Explorer, right-click the HelloWorld4 project and click Set as StartUp Project.
From the Debug menu, click Start Without Debugging.
Press any key to close HelloWorld4.
To build and run the Hello World samples from the Command Line
Use the Change Directory command to change to the HelloWorld directory.
Type the following:
cd HelloWorld1 csc Hello1.cs Hello1
Type the following:
cd ..\HelloWorld2 csc Hello2.cs Hello2
Type the following:
cd ..\HelloWorld3 csc Hello3.cs Hello3 A B C D
Type the following:
cd ..\HelloWorld4 csc Hello4.cs Hello4