C# is a simple & powerful object-oriented programming language developed by Microsoft. C# can be used to create various types of applications, such as web, windows, console applications, or other types of applications using Visual studio.
C# Version History
C# was first introduced with .NET Framework 1.0 in the year 2002 and evolved much since then. The following table lists important features introduced in each version of C#:
| Version | .NET Framework | Visual Studio | Important Features |
|---|---|---|---|
| C# 1.0 | .NET Framework 1.0/1.1 | Visual Studio .NET 2002 |
|
| C# 2.0 | .NET Framework 2.0 | Visual Studio 2005 |
|
| C# 3.0 | .NET Framework 3.0\3.5 | Visual Studio 2008 |
|
| C# 4.0 | .NET Framework 4.0 | Visual Studio 2010 |
|
| C# 5.0 | .NET Framework 4.5 | Visual Studio 2012/2013 |
|
| C# 6.0 | .NET Framework 4.6 | Visual Studio 2013/2015 |
|
| C# 7.0 | .NET Core 2.0 | Visual Studio 2017 |
|
| C# 8.0 | .NET Core 3.0 | Visual Studio 2019 |
|
| C# 9.0 | .NET 5.0 | Visual Studio 2019 |
|
| C# 10.0 | .NET 6.0 | Visual Studio 2022 |
|
Learn how to setup a development environment for C# .
First C# Program
Here, you will learn to create a simple console application in C# and understand the basic building blocks of a console application.
C# can be used in a window-based, web-based, or console application. To start with, we will create a console application to work with C#.
Open Visual Studio (2017 or later) installed on your local machine. Click on File -> New Project... from the top menu, as shown below.

From the New Project popup, shown below, select Visual C# in the left side panel and select the Console App in the right-side panel.

In the name section, give any appropriate project name, a location where you want to create all the project files, and the name of the project solution.
Click OK to create the console project. Program.cs will be created as default a C# file in Visual Studio where you can write your C# code in Program class, as shown below. (The .cs is a file extension for C# file.)

Every console application starts from the Main() method of the Program class. The
following example displays "Hello World!!" on the console.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSharpTutorials
{
class Program
{
static void Main(string[] args)
{
string message = "Hello World!!";
Console.WriteLine(message);
}
}
}
The following image illustrates the important parts of the above example.

Let's understand the above C# structure.
- Every .NET application takes the reference of the necessary .NET framework namespaces that it is
planning to use with the
usingkeyword, e.g.,using System.Text. - Declare the namespace for the current class using the
namespacekeyword, e.g.,namespace CSharpTutorials.FirstProgram - We then declared a class using the
classkeyword:class Program - The
Main()is a method ofProgramclass is the entry point of the console application. Stringis a data type.- A
messageis a variable that holds the value of a specified data type. "Hello World!!"is the value of the message variable.- The
Console.WriteLine()is a static method, which is used to display a text on the console.
Compile and Run C# Program
To see the output of the above C# program, we have to compile it and run it by pressing Ctrl + F5 or clicking the Run button or by clicking the "Debug" menu and clicking "Start Without Debugging". You will see the following output in the console:
So this is the basic code items that you will probably use in every C# code.