C# (.NET)

C# is a modern, statically typed language in the .NET ecosystem. Once Windows-only, modern .NET is cross-platform, fast, and production-proven, powering backend services, desktop apps, cloud workloads, and games (via Unity).

Its strengths are excellent tooling (first-class IDE support, debugging, profiling), a mature high-performance runtime, and a coherent, well-designed language that keeps adding modern features (records, pattern matching, nullable reference types). async/await — which C# pioneered — is central to how modern .NET code is written.

TL;DR

Quick Example

A minimal API endpoint returning a record — concise, typed, and fast:

Core Concepts

Async & Concurrency

Modern .NET is async-first:

Tooling

The dotnet CLI handles build/test/run/publish; NuGet is the package manager.

Best Practices

Comparison: C# vs Java

See Java.

Common Mistakes

Sync-over-async deadlocks

Unbounded parallelism

FAQ

Is C# only for Windows?

No — that's outdated. Modern .NET (formerly .NET Core) runs on Windows, Linux, and macOS, in containers and the cloud. The legacy .NET Framework was Windows-only, but new development targets cross-platform .NET.

What's a record and when should I use it?

A record is a concise reference (or struct) type with value-based equality and immutability by default — ideal for DTOs, domain values, and anything you compare by content rather than identity. It removes boilerplate (Equals, GetHashCode, with expressions).

Why is .Result/.Wait() dangerous?

Blocking on an async operation can deadlock when a synchronization context is involved (classic in older ASP.NET and UI apps), and it wastes a thread. Use await throughout instead of blocking.

C# or Java?

Both are mature, fast, statically typed languages. C#/.NET fits Microsoft-adjacent stacks, Unity game dev, and teams who like its modern language design. Java/JVM has the larger overall ecosystem and is the Android default. Choose by ecosystem and team familiarity.

Related Topics

References