Start with C#

C# or C sharp is a language which was introduced in 2000 by Microsoft. It has resemblance with both c++ and java and however it requires .NET framework to run. I used Visual Studio for writing my first C sharp program. You can easily download visual studio community edition from this link visual studio and go through the installation instruction there.


The program is to print Hello World in windows console. At first, I have to create a project in visual studio for the console application. Then I wrote the bunch of line of codes there.

using System;
namespace HelloWorld {
    class Program {
        static void Main(string[] args) {
            Console.WriteLine("Hello World");
            Console.ReadLine();
        }
    }
}

This chunk of code will print Hello World in the console as given in the image below.

The first line of code is ‘using System’ that means we are including the system library which we later used to print the line in the console by writing ‘Console.Writeline(“Hello World”)’. .NET framework has many such libraries which are built so that we as a programmer don’t have to think about how to print the line by using hardware resources and managing memory. We just stick whatever we want in the console. Next one is ‘namepace HelloWorld’. Namespace in C# is used to separate one set of names from other. We will later come to the more details of each line.

We might face an error if there some mistake. Visual Studio helps us to avoid that by drawing a red underline if there is some syntactical mistake like this image

It also helps in auto-completing the code. In the later sections, we will discuss more details about these lines of codes and go through some data types in C#.

Leave a Reply

Your email address will not be published. Required fields are marked *