One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man

Friday, December 27, 2013

C# Part 1 : Hello World Program

This is a starting of new tutorial series for C# beginners. You don't need to have big experiences with any programming language and I am expecting very basic computer knowledge as an requirement.

I am conducting this sessions using 'Microsoft Visual Studio 2010' product. If you don't have licence version of that you can download free light version called 'Visual C# 2010 Express' from the Microsoft official web site.

Now we are going to write the "Hello World" program.

Step 1 : Open Visual Studio 2010 software

Step 2 : Then create a new project

File -> New -> Project

As the first program we are going to create a console C# application. Once you got the New Project window, follow the instructions in the above picture and press OK to create the project.

Then it will generate a simple program automatically for you. After that you can add following lines to the Main() method (which is the starting point of the program).

Console.WriteLine("Hello World");

Following picture describe the program properly.

1) Namespaces used by the program (Actually this small program required only 'System' namespace). Namespace is a collection of Classes, Delegates, Enums and Namespaces which we will go in depth in next tutorials.

2) Namespace of the current class

3) Declaration of the class (In this case the class name is 'Program')

4) Starting point of the program

5) Ending point of the program

6) 'WriteLine()' is the method inside the 'Console' class that we use to write something to the console. 'Console' class is in the 'System' namespace.

7) 'ReadLine()' is the method inside the 'Console' class that we use to read user inputs from the console (In this case we use this method to wait the program until we press any key).

Please put a comment if you have any doubts. Play around with this code and ask any question regarding the issues you faced. See you in the next tutorial.