Tuesday, February 2, 2016

Hello World!

Starting C# in Visual Studio

(Click any images throughout to enlarge)

  1. The first step would be to open a Console Application in Microsoft Visual Studio.
    • To do this, Click on File --> New --> Project...
    • Once you have done this, a screen will come up prompting you to select the type of project you wish to open, and giving your project a name.
    • Set up your application by choosing Console Application from the Visual C# menu, select a location to save your project to, and name your project HelloWorld as shown below:

  2. Once you have completed this step, a window named Project.cs will open as shown below:

  3. Now it is time to add our code. We simply will need 3 lines in the Main function to produce our HelloWorld! example. (Note: the semi-colon is used to end a command as in Java)



  4. The "Console.WriteLine" commands will do exactly as they say in the console, they will write lines. The "Console.ReadKey" command will close the program when the user presses any key.
  5. Finally, press the button on the toolbar. and your HelloWorld! program will run. The output is shown below:


After the output is displayed, you can press any key to exit the program, and you are done! You have created your first C# program. At this point, you can save your program, and exit Microsoft Visual Studio.


    1 comment:

    1. This language definitely has similar syntax to other object oriented languages! Very simple command to print a statement.

      ReplyDelete