Intro
C# is Microsofts flagship language: strongly typed, garbage collected, runs on .NET. Modern features, excellent tooling, and cross-platform.
C# — what it is
EXAMPLE
// ===== The values =====
// - Strong static typing with great inference (var, records, nullable refs)
// - .NET runtime: cross-platform, performant, mature
// - First-class async/await
// - Massive enterprise ecosystem (Web APIs, MAUI, Unity)
// ===== Hello, world =====
Console.WriteLine("hello, world");
// Top-level statements remove Main boilerplate.
// dotnet new console; dotnet run
// ===== Records + pattern matching =====
public record User(int Id, string Name, string Email);
var u = new User(1, "Alex", "a@x.io");
var size = u.Id switch {
< 10 => "small",
< 100 => "medium",
_ => "large",
};
// ===== Async by default =====
public async Task<string> FetchTitleAsync(string url)
{
using var http = new HttpClient();
return await http.GetStringAsync(url);
}
// ===== Minimal Web API (ASP.NET Core) =====
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/healthz", () => Results.Json(new { ok = true }));
app.Run();
// dotnet run -> http://localhost:5000/healthz
// ===== When C# wins =====
// - Enterprise systems
// - Game development (Unity)
// - Cross-platform desktop (.NET MAUI)
// - High-performance APIs (Kestrel + minimal APIs are very fast)
// ===== When C# hurts =====
// - Quick dynamic scripting (Python wins)
// - Anywhere you'd rather not depend on .NET runtime tooling
// ===== Patterns to internalise =====
// - Records for DTOs
// - Nullable reference types enabled in every project
// - async all the way down at IO boundaries
// - DI built into ASP.NET Core; don't roll your own
// ===== Pitfalls =====
// - Using .Result on a Task -> deadlocks in UI / ASP.NET
// - Disabling nullable warnings to silence errors -> hides real bugs
// - Catching general Exception broadly
// - Manually managing connections instead of using async + 'using'
Why it matters
C# in 2026 is a modern, ergonomic language with one of the best runtimes around. Records, nullable refs, pattern matching, minimal APIs — the language has matured into something that ships features fast and runs fast. Reach for it for serious backends, Unity, or cross-platform desktop.
Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.
Example
Example
// C#: statically typed, OOP, runs on .NET. // Modern features: records, top-level statements, async/await, LINQ.Try it Yourself »
Exercise
Print a line to the console.
Console.
("Hello");
PascalCase WriteLine.
Discussion
Loading…