Getting started with C#

Posted on Updated on

image[32]Getting started with C#

To run a simple console based application, just follow the steps given –

  1. Start Visual Studio
  2. From the Menu bar, select File -> New Project The New Project Dialog Box appears
  3. Go to Installed and expand it, then move to Templates and then to Visual C#, and then choose Console Application.
  4. Give the Name of your project in the Name Box, and then click OK button.
  5. The New project appears in Solution Explorer
  1. cs opens in the code window.
  2. Write the following content to your Program

Line 1  // A Hello World! program in C#.

Line 2  using System;

Line 3      class Hello

Line 4      {

Line 5          static void Main()

Line 6          {

Line 7  Console.WriteLine(“Hello World!”);

Line 8  Console.WriteLine(“Press any key to exit.”);

Line 9  Console.ReadKey();

Line 10                  }

Line 11              }

  1. To run the project press F5 key


Hello World!


Line 1

// A Hello World! program in C#. 

The line above is a single line comment. The characters written after ‘//’ will get converted to comments and will be ignored by the compiler.

Besides Single line comment, multiline comment is also there, which comments the block of text. To add multiline comment enclose the text in between /* and */

/* This block depicts

multiline comment


Line 2

using System;

This directive references a namespace System, which is present in Microsoft .Net Framework class library. A Console class is present in this namespace, which is used in the Main method

Line 3

class Hello

This line represents the name of the class. It is recommended that it should start with Capital letter.

Line 4


Beginning of the class

Line 5

static void Main()

Every console application must contain a Main method. Inside the Main(), objects are created and other codes that are to be executed are placed. It is a static method.. This is the entry point of the application; the program starts execution when the main method is called.

Line 6


Starting of the Main() method

Line 7-8

Console.WriteLine(“Hello World!”);

Console.WriteLine(“Press any key to exit.”);

The WriteLine() method is the output method of the Console class in the run-time library. It displays the string on the output stream on a new line. If System namespace is not included in the program, System.Console.WriteLine() has to be used instead ofConsole.WriteLine().



It waits for any key to be pressed from the keyboard.

Line 10


Closing of Main()

Line 11


Closing of class Hello


For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.
Helpline: 9814666333, 8699444666

Please fill the form and we shall contact you soon.


Leave a Reply

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

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