Learn C#

C# (pronounced "C sharp") is a modern, general-purpose programming language created by Microsoft. It runs on the .NET platform and is used to build everything from desktop apps and websites to games and mobile apps. In this lesson you will learn what C# is, why it is so popular, and what you can create with it.

What is C#?

C# is an object-oriented programming language that was first released in 2000. It was designed to be simple, safe, and productive while still being powerful enough for large professional applications. Because it runs on .NET, the same C# code can run on Windows, macOS, and Linux.

A tiny C# program looks like the example below. Do not worry about understanding every word yet, we will break it down in later lessons. For now, notice that the line inside prints a message to the screen.

Your first look at C#

using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, and welcome to C#!");
    }
}

Why learn C#?

  • It is one of the most popular programming languages in the world.
  • It is easy to read and learn, with a clear and consistent syntax.
  • It powers Windows apps, web apps with ASP.NET, and games built in the Unity engine.
  • It has a huge community, so help and free learning material are everywhere.
  • The skills you learn transfer easily to related languages like Java and C++.

Because C# is a compiled language, your code is checked for many mistakes before it ever runs. This helps you catch errors early and write more reliable programs.

Note: C# and the .NET platform are free and open source. You can build and run C# programs on any major operating system without paying for anything.

What can you build with C#?

AreaWhat you can create
DesktopWindows applications and cross-platform tools
WebWebsites and web APIs using ASP.NET Core
Games2D and 3D games with the Unity engine
MobileiOS and Android apps using .NET MAUI
CloudScalable services that run on cloud servers

C# can do math too

using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("C# can calculate:");
        Console.WriteLine(10 + 5);
    }
}

Exercise: C# Introduction

Which company originally developed the C# language?

Frequently Asked Questions

What is C# used for?
Windows desktop applications, backend web services with ASP.NET, and games through Unity, which is the dominant engine for indie and mobile titles. It also runs cross-platform on Linux and macOS through .NET.
Is C# easier than Java?
They are close in difficulty and syntax. C# has more built-in conveniences, such as properties, LINQ and async/await, which usually means less boilerplate for the same work.
Is C# good for game development?
Yes. Unity uses C# as its scripting language, so it is the most direct route into professional game development, and Godot supports it as well.