Hello world in C#

// A Hello World! program in C#
using System;
namespace HelloWorld
{
    class Hello
    {
        static void Main()
        {
            System.Console.WriteLine(“Hello World!”);

            // Keep the console window open in debug mode.
            System.Console.WriteLine(“Press any key to exit.”);
            System.Console.ReadKey();
        }
    }
}

Here the first line starts with the // sign which indicates that the line is comment and has nothing to do with the programming. This comment helps you to understand what your code is so that in future if you see the code it would not be hard for you to understand what you have written. The Second line ‘using system;’indicates the namespaces that your program must have in order to access the functions. As being the object oriented programming the concept of class must be understood. And lastly there is the void main() function which is invoked as soon as the program is launched. and there you can see the ‘writeline()’ function which consists of the text hello world in it, that means this line of code writes the hello world to the console screen. The last line code which is readkey() reads the key entered by the user. That is all you have to understand about the starting program of hello world. Happy C#ing.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s