C# tutorial

last modified January 10, 2023

This is C# tutorial. In this tutorial you will learn the basics and some advanced topics of the C# language.

The basics of C# are covered in C# basics, C# lexical structure, C# variable, C# statement, C# flow control, C# operator, C# data type.

Object-oriented programming is covered in C# class, C# object, and C# OOP.


C# is a modern, high-level, general-purpose, object-oriented programming language. It is the principal language of the .NET. It supports functional, procedural, generic, object-oriented, and component-oriented programming disciplines.

The design goals of the language were software robustness, durability and programmer productivity. It can be used to create console applications, GUI applications, web applications, both on PCs and embedded systems. C# was created by Microsoft corporation.


.NET is an open-source, general-purpose development platform maintained by Microsoft and the .NET community on GitHub. With .NET, we can use multiple languages, editors, and libraries to build for web, mobile, desktop, games, and IoT.

$  dotnet --version

In order to work with .NET, we need to dowload and install .NET SDK. The .NET 6 supports C# 10.0.

Compiling C# programs

After installing .NET SDK, we can build our first C# program.

$ dotnet new console -o Simple

With the dotnet new console command, we create a new console application.

Console.WriteLine("This is C#");

This is a simple C# program that prints a message to the console.

$ dotnet run
This is C#

We compile and run a simple C# program with dotnet run.

Visual Studio Code

Visual Studio Code is a lightweight, powerful, modern source code editor which is available for Windows, macOS and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages and runtimes including C# and .NET.

It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring.

List all C# tutorials.