This sample shows several versions of a Hello World program in C#.
To get samples and instructions for installing them
Security Note: |
|---|
|
This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.
|
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 then click Set as StartUp Project.
On the Debug menu, click Start Without Debugging.
Press any key to close HelloWorld1.
In Solution Explorer, right-click the HelloWorld2 project, and then click Set as StartUp Project.
On the Debug menu, click Start Without Debugging.
Press any key to close HelloWorld2.
In Solution Explorer, right-click the HelloWorld3 project, and then click Set as StartUp Project.
In Solution Explorer, right-click the HelloWorld3 project, and then click Properties.
Open the Configuration Properties folder, and then click Debug.
In the Command Line Arguments property, type A B C D and then click OK.
On the Debug menu, click Start Without Debugging.
Press any key to close HelloWorld3.
In Solution Explorer, right-click the HelloWorld4 project, and then click Set as StartUp Project.
On the Debug menu, click Start Without Debugging.
Press any key to close HelloWorld4.
To build and run the Hello World samples from a command prompt
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
Concepts
Reference