Introduction to C#
C# is a general-purpose, statically-typed language built by Microsoft and run on .NET. It shows up in Windows desktop software, web backends, mobile apps, and a large slice of the game industry through Unity — and it's compiled, which catches a category of mistakes before your program ever runs.
C# and .NET
C# is the language; .NET is the platform underneath it. When you write C# code, it doesn't get turned directly into instructions your processor understands. Instead, the compiler turns it into an intermediate form called IL (Intermediate Language), and the .NET runtime — the CLR, or Common Language Runtime — translates that into native machine code the moment it actually needs to run. This two-step process is why the same compiled C# program can run on Windows, macOS, or Linux without changes: the CLR handles the platform-specific part.
You'll see C# used in quite different corners of software: ASP.NET Core for web servers and APIs, .NET MAUI for cross-platform mobile and desktop apps, Unity for games, and plain console applications — which is where this course starts, because it's the fastest way to focus on the language itself without extra scaffolding.
Running a console app
If you have the .NET SDK installed, creating a new project is one command:
// scaffolds a new console project in the current folder dotnet new console // compiles and runs it dotnet run
That generates a file named Program.cs with a single line already in it. Everything in this course after this point assumes that line lives inside a file like that one — we won't repeat the project-creation step in every example.
Your first program
Modern C# (the style dotnet new console gives you today) lets you write top-level statements — no wrapping class or method required just to say hello:
Console.WriteLine("Hello, world!"); Console.WriteLine("Welcome to C#.");
Hello, world! Welcome to C#.
Older C# code — and plenty of code you'll still run into — wraps the same logic in an explicit class and a Main method. It behaves identically; it's just the older required ceremony:
using System; class Program { static void Main() { Console.WriteLine("Hello from Main!"); } }
Hello from Main!
Write vs. WriteLine
Console.WriteLine prints its text and then moves to a new line. Console.Write prints the text and leaves the cursor right where it stopped — useful when you're building up one line piece by piece:
Console.Write("Loading"); Console.Write("..."); Console.WriteLine("done!");
Loading...done!