I’m Learning C# – Part 2

Hope the visual studio community edition is installed and running.

Let’s create our first program using it.


Once the code is written, you will build it and then play it. The green colour on the side of the code indicates the code is saved or build. Otherwise it will be yellow in colour.

This is the basic Hello World Program. Main points to note are every code you write should have a main () function, that’s where the execution begins.

Noticed a WriteLine – This will send the cursor to the next line after “Hello World” is displayed. You can use just Write if you don’t want a newline.

Console is the output window where the string will be displayed to the user.

Now that we know how to display something to the user, we need to learn how to get some user input.

ReadLine is the command to read something from the console window.  Try the following code snippet inside the main function.

String message;
Console.WriteLine(“Enter your name”);
message = Console.ReadLine();
Console.WriteLine(“Hello {0}”, message);

To make the code meaningful we use comments. eg: int age; // declaring age

We can have comments extending over multiple lines by /* …….. */


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s