Export (0) Print
Expand All

Hello World Sample

This sample shows several versions of a Hello World program in C#.

This sample contains the source code for the Hello World Tutorial.

Building and Running the Sample Within Visual Studio

To build and run the Hello World samples

  1. Open the solution (HelloWorld.sln).
  2. In Solution Explorer, right-click the HelloWorld1 project and click Set as StartUp Project.
  3. From the Debug menu, click Start Without Debugging.
  4. Press any key to close HelloWorld1.
  5. In Solution Explorer, right-click the HelloWorld2 project and click Set as StartUp Project.
  6. From the Debug menu, click Start Without Debugging.
  7. Press any key to close HelloWorld2.
  8. In Solution Explorer, right-click the HelloWorld3 project and click Set as StartUp Project.
  9. In Solution Explorer, right-click the HelloWorld3 project and click Properties.
  10. Open the Configuration Properties folder and click Debugging.
  11. In the Command Line Arguments property, type "A B C D" and click OK.
  12. From the Debug menu, click Start Without Debugging.
  13. Press any key to close HelloWorld3.
  14. In Solution Explorer, right-click the HelloWorld4 project and click Set as StartUp Project.
  15. From the Debug menu, click Start Without Debugging.
  16. Press any key to close HelloWorld4.

Building and Running the Sample from the Command Line

To build and run the Hello World samples

  1. Use the Change Directory command to change to the HelloWorld directory.
  2. Type the following:
    cd HelloWorld1
    csc Hello1.cs
    Hello1
    
  3. Type the following:
    cd ..\HelloWorld2
    csc Hello2.cs
    Hello2
    
  4. Type the following:
    cd ..\HelloWorld3
    csc Hello3.cs
    Hello3 A B C D
    
  5. Type the following:
    cd ..\HelloWorld4
    csc Hello4.cs
    Hello4
    

See Also

Hello World Tutorial | Tutorial Samples

Show:
© 2014 Microsoft