C#, also pronounced as C-sharp, is a widely used programming language developed by Microsoft and runs on .NET framework. It was developed in the year 2002, and its syntax and object-oriented programming approaches and principles are quite similar to C++ and Java. So, if you are familiar with any of these language, then learning C# is straightforward for you. Even in the modern days, many of the top-tiered companies still use C# to build a wide range of applications including desktop applications, web applications, mobile applications (Xamarin), game development (Unity), cloud computing (Microsoft Azure), AI, Augmented reality and Virtual Reality, and so on. Top companies still using C# are: Microsoft, Intel, IBM, Adobe, Dell, Amazon, and so on.
Due to the continuous improvement to the C# by Microsoft and the programming community, C# is getting more and more demanded nowadays than the other programming language. .NET provides libraries and tools to make applications development faster and efficient in C#. The most current version of C# is C#13 that runs with .NET 9 SDK version. .NET SDK (Software Development Kit) is a software building tool for C# programming language.
If you want to learn C#, then one thing I find the easiest one was using Visual Studio Code, developed by Microsoft and is very light-weight. There's a lot of libraries and extensions built by Microsoft that you can install inside the visual studio code. Downloading Visual Studio code is pretty simple and so is the libraries and extensions pack required for learning C# in the visual studio code. If you have downloaded visual studio code, just install these three important extensions: .NET SDK 9, .NET extension pack, and C# Dev kit, all created by Microsoft that you can easily find there in visual studio code.
Now we will create a simple C# program to print a Hello World. For that we will create a new folder, and you can name anyway you like. I will open that folder, then right click and select "Open Visual Studio Code". It will open a visual studio code. Now open a terminal in VS code and run dotnet new console
. It will create some files for us that you don't need to worry about.
As you can see it automatically created a program C# file with some automatic code. If you write dotnet run
in the terminal you can see the output but we will do it the right way by writing everything. So delete that two line code in program.cs
file and write the following code:
using System;
class Program{
static void Main()
{
Console.WriteLine("Hello, World. Welcome to C# Programming Language");
}
}
The output for above code while compiling and running will be as below:
Now we will see a breakdown of what each syntax means and what it does in C# programming.
using System
: This means we are using system namespace and its built-in classes and functions. Example: console classes and WriteLine functions in above code.class Program{}
: C# should contain at least one class for the entry point and Program does that.static void Main()
: Any code that goes inside this one is the main code that will be executed and is the main program.Console.WriteLine
: As explained above, it will print the above statement.
The important thing to remember in C# programming language is the use of semi-colon (;). And C# is case-sensitive as well. Hope that covers the general introduction to C# programming language. Stay tune for more!!!