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 /* …….. */


I’m Learning C# – Part 1

C# pronounced as See Sharp. A more powerful object oriented programming language than C++. The # symbol has 4 + (plus) in it to show its superiority to C++.

Applications written in C# make use of the .Net Framework. The .NET Framework consists of Common Language Runtime (CLR) and Frame work class library (FCL).

Variables – To store some data, we make use of variables. It will allocate some memory to store this data.It is possible to change the information that a variable holds during runtime. A variable name can start with an alphabet or an ‘_’. Try to make the name meaningful or descriptive. This is a good coding practice.

Variable Data types – We need to declare the type of data that our variable will store and how much memory need to be allocated to it.

Eg: We need to store the age of a person. We use the data type int.

int age;

; is used for terminating each line of code. Now we need to assign a value to our variable age. It can be done in 2 ways.

int age; age = 32;

or int age = 32;

The only thing to remember is that you need to declare the data type of a variable before you assign value to that variable. Other data types are float, bool, char, string, double – all of these are built-in data types.

There’s a data type called var for which you let the compiler decide the variables’ data type. var a = 2; means the compiler will assign the data type of integer to the variable a.

Constants – A variable whose value you do not want to change during the execution of a code is associated with the keyword const. eg: Const int year = 2017;

Download and install Visual Studio Community Edition to start coding. Choose default configuration. It would take a while to install 🙂