C# is a statically typed, object-oriented language built by Microsoft and run on .NET. It is used for web back ends, desktop applications, cloud services and games — Unity uses it as its scripting language. Since .NET became cross-platform it runs equally well on Windows, macOS and Linux, which removed the main reason people used to rule it out.
C# and .NET are different things#
C# is the language — the syntax you write. .NET is the platform it runs on: the runtime that executes your code, plus a large standard library covering collections, files, networking, JSON and much else.
The relationship is the same as Java to the JVM. You write C#, the compiler produces intermediate language, and the .NET runtime turns that into machine code as the program runs. Other languages target .NET too — F# and Visual Basic — but C# is by far the most used.
What people build with it#
| Area | Typical technology |
|---|---|
| Web back ends and APIs | ASP.NET Core |
| Games | Unity |
| Desktop applications | WPF, WinUI, Avalonia, MAUI |
| Cloud and serverless | Azure Functions, containers |
| Command-line tools | the base library plus System.CommandLine |
| Cross-platform mobile | .NET MAUI |
It is particularly common in business and enterprise settings, which is worth knowing if you are weighing it up for employment reasons.
Installing and running#
dotnet --version
Download the .NET SDK from Microsoft’s site if that command is not found. The SDK includes the compiler, the runtime and the dotnet tool.
dotnet new console -n HelloApp
cd HelloApp
dotnet run
Three commands from nothing to a running program. For an editor, Visual Studio on Windows, or VS Code with the C# Dev Kit extension anywhere.
Your first program#
Console.Write("What is your name? ");
string? name = Console.ReadLine();
Console.Write("How old are you? ");
if (int.TryParse(Console.ReadLine(), out int age))
{
Console.WriteLine($"Hello {name}, next year you will be {age + 1}.");
}
else
{
Console.WriteLine("That was not a number.");
}
Modern C# allows this without a class wrapper — top-level statements. The older full form still appears everywhere and is what you will see inside larger projects:
using System;
namespace HelloApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello");
}
}
}
What the language looks like#
// Types are declared and checked at compile time
int count = 42;
double price = 12.99;
decimal money = 19.99m; // decimal for currency
string name = "Ana";
bool ready = true;
var inferred = count * 2; // still an int, just inferred
// Nullable types
string? maybeName = null;
int? maybeCount = null;
// Conditions
string grade = score switch
{
>= 80 => "A",
>= 70 => "B",
_ => "F",
};
// Loops
foreach (var fruit in fruits) Console.WriteLine(fruit);
for (int i = 0; i < 5; i++) Console.WriteLine(i);
// Collections
var names = new List<string> { "Ana", "Sam" };
var ages = new Dictionary<string, int> { ["Ana"] = 34 };
// LINQ - querying collections
var adults = people.Where(p => p.Age >= 18)
.OrderBy(p => p.Name)
.ToList();
Classes and records#
public class Person
{
public string Name { get; set; }
public int Age { get; private set; }
public Person(string name, int age)
{
Name = name;
Age = age;
}
public bool IsAdult => Age >= 18;
public void HaveBirthday() => Age++;
}
// A record - for data that is defined by its values
public record Point(double X, double Y);
var a = new Point(1, 2);
var b = new Point(1, 2);
Console.WriteLine(a == b); // True - compares values
var moved = a with { X = 5 }; // copy with one change
That single record line replaces a constructor, two properties, equality, hashing and a readable ToString.
Static typing, and what it buys#
int count = "hello"; // compile error, before the program ever runs
The compiler catches type mistakes, so a whole category of bug never reaches run time. The cost is more to write and a compile step; the benefit is that large codebases stay manageable and your editor can autocomplete and refactor reliably.
Python and JavaScript check types as the code runs, so the same mistake surfaces only when that line executes — possibly in production.
How it compares#
| C# | Java | Python | JavaScript | |
|---|---|---|---|---|
| Typing | static | static | dynamic | dynamic |
| Runs in a browser | no | no | no | yes |
| Learning curve | moderate | moderate | gentle | moderate |
| Strongest in | business apps, games | enterprise, Android | data, scripting | web front ends |
C# and Java are close relatives — knowing one makes the other largely readable. C# has moved faster in recent years, picking up records, pattern matching, nullable reference types and top-level statements.
What to learn, in order#
- Types, variables and string interpolation
- Conditions and loops
- Methods — parameters, return values, overloads
- Collections — lists, dictionaries, arrays
- Classes and objects — properties, constructors, inheritance
- LINQ — it replaces a great deal of loop writing
- Exceptions and the TryParse pattern
- async and await
Then pick a direction: ASP.NET Core for web work, Unity for games, or MAUI for applications.
Questions people ask#
Do I need Windows?
No. .NET runs on macOS and Linux, and VS Code works everywhere. Only some older desktop frameworks are Windows-only.
What is the difference between .NET Framework and .NET?
.NET Framework is the old Windows-only version, still maintained for existing applications. Modern .NET — version 5 and later — is cross-platform and is what new projects use.
Is C# good for beginners?
It is a reasonable first language, though there is more to learn before your first program runs than in Python. The type system helps once projects grow beyond a single file.
Is Unity a good reason to learn it?
Yes — Unity scripting is C#, and everything you learn transfers to ordinary C# development. It is one of the more motivating ways in.
Where to go next#
- C# basics — the syntax in more depth.
- Object-oriented programming in C# — classes properly.
- C# advanced language features — LINQ, generics and async.