Skip to content
C# logo

C#

First appeared 2000 · Anders Hejlsberg

Microsoft's flagship language — pragmatic, feature-rich, and no longer Windows-only.

Overview

C# (pronounced 'C-sharp') is a modern, versatile, object-oriented programming language developed by Microsoft as part of its .NET initiative. Released in 2000 as a cornerstone of the .NET Framework, C# was designed to combine the computational power and flexibility of C++ with the simplicity and productivity of modern languages like Java and Visual Basic. C# is a statically typed, strongly typed language that supports multiple programming paradigms including object-oriented, functional, imperative, declarative, component-oriented, and generic programming, making it exceptionally flexible for various types of software development. The language features automatic memory management through an efficient garbage collector, comprehensive type safety that catches errors at compile time, LINQ (Language Integrated Query) for querying data from various sources using a unified syntax, async/await for writing asynchronous code that's easy to read and maintain, properties and events as first-class language features, delegates and lambda expressions for functional programming, and extensive library support through the massive .NET ecosystem. C# includes powerful features like generics for type-safe reusable code, nullable reference types to eliminate null reference exceptions, pattern matching for expressive conditional logic, records for immutable data types, tuples for returning multiple values, extension methods for adding functionality to existing types, and attributes for declarative programming. The language provides excellent support for modern software development practices including dependency injection, unit testing, and design patterns. C# is widely used for developing Windows desktop applications with WPF or WinForms, web applications and APIs with ASP.NET and ASP.NET Core, mobile applications with Xamarin and .NET MAUI, game development with Unity (the world's most popular game engine), cloud services on Microsoft Azure, machine learning with ML.NET, and enterprise software across virtually every industry. With the introduction of .NET Core in 2016 and its evolution into .NET 5, 6, 7, and beyond, C# has become truly cross-platform, running efficiently on Windows, macOS, and Linux, while maintaining excellent performance and a unified development experience. The language comes with outstanding tooling through Visual Studio, Visual Studio Code, and JetBrains Rider, providing intelligent code completion, powerful debugging, profiling, refactoring tools, and comprehensive testing frameworks. C# has a massive, active community, extensive documentation, countless learning resources, and a rich ecosystem of libraries and frameworks available through NuGet, the .NET package manager. The language continues to evolve rapidly with new versions released annually, adding modern features while maintaining backward compatibility and focusing on developer productivity, performance, and safety.

Key facts

The reference details, without the paragraph.

First appeared
2000
Designed by
Anders Hejlsberg at Microsoft
Typing
Static, strong and nominal, with local inference (`var`) and nullable reference types
Execution
Compiled to IL, JIT-compiled by the .NET runtime (or AOT-compiled to a native binary)
Memory model
Automatic — generational garbage collection, with `struct` and `Span<T>` for stack-friendly work
Package manager
NuGet
File extensions
.cs, .csproj, .sln
Current version
C# 14 on .NET 10 (LTS, November 2025)
Release cadence
One .NET release each November; even-numbered versions are LTS
Licence
MIT — the runtime, compiler and libraries are open source

History

How the language got here — the decisions that still shape how you write it.

C# was developed by Microsoft and led by Anders Hejlsberg, a legendary language designer who previously created Turbo Pascal at Borland and was the chief architect of Delphi. The development of C# began in the late 1990s as part of Microsoft's ambitious .NET initiative, which aimed to create a comprehensive platform for building and running applications across different types of devices and services. The project was initially called 'Cool' (C-like Object Oriented Language) before being renamed to C#, with the '#' symbol representing four '+' signs arranged in a grid, suggesting C++++ or an evolution beyond C++. The first version of C# was released in 2000 alongside the .NET Framework 1.0, and it was designed to be a simple, modern, general-purpose, object-oriented language that could leverage the full power of the .NET Framework. Microsoft's motivation for creating C# was multifaceted: they wanted a language that combined the best features of Java and C++ while addressing their limitations, a language that was designed specifically for the .NET platform rather than adapted to it, and a language that could compete with Java which was gaining significant traction in enterprise development. There were also legal and strategic considerations, as Microsoft wanted a language they fully controlled without the licensing and legal complexities associated with Java. C# was designed with several key principles: simplicity (easier to learn and use than C++), type safety (catching errors at compile time), component-oriented (supporting properties, events, and attributes), and modern (incorporating the best ideas from contemporary language design). The language drew inspiration from many sources: C++ for its syntax and performance characteristics, Java for its simplicity and garbage collection, Delphi for its component model and RAD (Rapid Application Development) capabilities, and various other languages for specific features. The initial release of C# 1.0 included classes, structs, interfaces, events, properties, delegates, and other fundamental features. C# 2.0, released in 2005, added generics (a major addition that enabled type-safe collections and algorithms), nullable types, anonymous methods, and iterators. C# 3.0, released in 2007, introduced LINQ (Language Integrated Query), one of the most significant features ever added to the language, along with lambda expressions, extension methods, anonymous types, and automatic properties. LINQ revolutionized how developers work with data, providing a unified syntax for querying objects, databases, XML, and other data sources. C# 4.0 (2010) added dynamic typing for better interoperability with dynamic languages and COM, named and optional parameters, and covariance/contravariance for generics. C# 5.0 (2012) introduced async/await, which transformed asynchronous programming by making it as easy to write as synchronous code while maintaining the benefits of non-blocking operations. This feature has been widely praised and copied by other languages. C# 6.0 (2015) brought numerous quality-of-life improvements including null-conditional operators, string interpolation, and expression-bodied members. A major turning point came in 2016 with the release of .NET Core, a cross-platform, open-source reimplementation of .NET that could run on Windows, macOS, and Linux. This marked a significant shift in Microsoft's strategy, making C# and .NET truly cross-platform and open-source. The .NET Foundation was established to govern the open-source .NET ecosystem, with contributions from Microsoft and the community. C# 7.0 (2017) introduced tuples, pattern matching, local functions, and out variables. C# 8.0 (2019) added nullable reference types (a major safety feature), async streams, ranges and indices, and default interface methods. C# 9.0 (2020) brought records for immutable data types, init-only properties, and top-level statements. C# 10.0 (2021) added global usings, file-scoped namespaces, and record structs. C# 11.0 (2022) introduced raw string literals, required members, and list patterns. Each version has built upon the previous ones while maintaining backward compatibility, ensuring that existing code continues to work. Throughout its history, C# has been used to build countless applications across every domain. Microsoft uses C# extensively for its own products including Visual Studio, Azure services, and many Windows components. Stack Overflow, one of the world's largest developer communities, is built with C# and ASP.NET. Unity, the game engine used to create a huge percentage of mobile games and many PC/console games, uses C# as its scripting language, introducing millions of game developers to the language. Companies across industries including finance, healthcare, retail, manufacturing, and technology use C# for their enterprise applications, web services, and internal tools. The language has been particularly successful in enterprise environments where its strong typing, excellent tooling, comprehensive frameworks, and Microsoft's enterprise support make it an attractive choice. C# has also found success in cloud computing, with Azure providing first-class support for .NET applications and many cloud-native applications being built with C# and ASP.NET Core. The evolution from .NET Framework to .NET Core to the unified .NET 5+ platform represents Microsoft's commitment to modernizing the platform while maintaining its strengths. The modern .NET platform is high-performance (often competing with or exceeding languages like Go and Node.js in benchmarks), cross-platform, open-source, and actively developed with regular releases. Anders Hejlsberg remains involved in C#'s development, though the language is now designed by a team at Microsoft with input from the community through the open design process on GitHub. C# continues to evolve with annual releases, each bringing new features, performance improvements, and enhanced developer productivity. The language's combination of power, productivity, safety, and versatility, backed by Microsoft's resources and a massive ecosystem, ensures its continued relevance and growth in modern software development.

  1. 2000

    C# and .NET announced

    Anders Hejlsberg, fresh from Delphi, designs a language for Microsoft's new managed runtime. Early C# is unmistakably a response to Java, sharing its shape while fixing several of its irritations.

  2. 2005

    C# 2.0 — generics done properly

    Unlike Java, C# implements generics with runtime reification rather than erasure, so `List<int>` really is a list of ints with no boxing. Nullable value types and iterators arrive too.

  3. 2007

    LINQ

    C# 3.0 adds lambdas, extension methods, anonymous types and query syntax. Querying collections, XML and databases through one uniform API is genuinely novel and remains a defining C# feature.

  4. 2012

    async/await

    C# 5.0 introduces the async model that JavaScript, Python, Rust and Kotlin all subsequently borrow. Asynchronous code that reads sequentially starts here.

  5. 2016

    .NET Core — cross-platform and open source

    A rewritten, MIT-licensed, cross-platform runtime. C# stops being a Windows language, and Linux containers become a first-class deployment target.

  6. 2020

    Nullable reference types

    C# 8 lets the compiler track which references may be null, addressing the billion-dollar mistake as an opt-in, gradually adoptable feature.

  7. 2021

    .NET 5 unifies the platform

    The old .NET Framework, .NET Core and Mono lines converge into a single product with an annual release cadence. Records, top-level statements and pattern matching modernise the language.

  8. 2025

    .NET 10 and C# 14

    Native AOT compilation matures, startup and memory improve substantially, and the language continues to absorb functional ideas — extension members, field-backed properties and richer patterns.

What it is good at

The reasons teams pick it, stated concretely.

  • Unusually complete out of the box

    Web APIs, desktop UI, games, mobile, cloud functions and machine learning all have first-party or well-supported paths. You rarely have to assemble a stack from unrelated projects.

  • LINQ

    One query syntax over in-memory collections, databases via Entity Framework, XML and JSON. Data transformation code in C# is consistently shorter and clearer than the equivalent in most comparable languages.

  • The best async model of its generation

    `async`/`await` originated here and remains exceptionally well integrated — cancellation tokens, `IAsyncEnumerable` and `ValueTask` cover the cases other ecosystems bolted on later.

  • Visual Studio and Rider

    Debugging, profiling, hot reload and refactoring are best-in-class. The developer experience is a genuine reason teams choose the platform.

  • Performance keeps improving

    `Span<T>`, `struct` types, source generators and native AOT let performance-sensitive C# approach native speed while staying memory-safe. Recent .NET releases have each delivered measurable, published throughput gains.

Trade-offs

Every language costs you something. Knowing what, before you commit, is the whole point.

  • A large and still-growing feature set

    Fifteen versions of additions mean several ways to write the same thing. Reading older code means recognising idioms from three different eras of the language.

  • The Microsoft-ecosystem gravity

    Everything works beautifully with Azure, SQL Server and Windows. It all works elsewhere too, but the documentation, defaults and tutorials assume the Microsoft path.

  • Legacy .NET Framework will not go away

    Plenty of production code targets the Windows-only .NET Framework 4.x, which is maintained but frozen. Migrating to modern .NET is often the largest item on a team's backlog.

  • Nullable reference types are opt-in

    The feature is genuinely valuable but has to be enabled per project, and mixing annotated and unannotated code produces warnings that are easy to switch off and then ignore.

  • Runtime footprint

    Standard deployments carry a JIT and garbage collector, so startup and memory are heavier than Go or Rust. Native AOT closes the gap at the cost of losing reflection-based features.

Code examples

Not syntax tours — the idioms that make code read like the language rather than a translation of another one.

LINQ turns loops into queries
record Sale(string Region, string Product, decimal Amount, DateOnly Date);

var topRegions = sales
    .Where(s => s.Date.Year == 2026)
    .GroupBy(s => s.Region)
    .Select(g => new { Region = g.Key, Total = g.Sum(s => s.Amount) })
    .OrderByDescending(r => r.Total)
    .Take(3)
    .ToList();

foreach (var (region, total) in topRegions.Select(r => (r.Region, r.Total)))
    Console.WriteLine($"{region,-10} {total,10:C}");
The same operators work over an in-memory list or, through Entity Framework, translate into SQL that runs on the database. Note that LINQ is lazy — nothing executes until `ToList()` or the `foreach` forces it.
Records, pattern matching and switch expressions
abstract record Payment;
record Card(string Last4, decimal Amount)      : Payment;
record Transfer(string Iban, decimal Amount)   : Payment;
record Cash(decimal Amount)                    : Payment;

static decimal FeeFor(Payment payment) => payment switch
{
    Card { Amount: > 1000 } c => c.Amount * 0.01m,
    Card c                    => c.Amount * 0.02m,
    Transfer                  => 0.50m,
    Cash                      => 0m,
    _ => throw new ArgumentOutOfRangeException(nameof(payment))
};
Property patterns match on shape and content at once, so the high-value card case is expressed declaratively rather than as a nested `if`. Records give value equality and a readable `ToString` with no extra code.
async/await with cancellation
public async Task<IReadOnlyList<string>> FetchAllAsync(
    IEnumerable<string> urls,
    CancellationToken cancellationToken = default)
{
    using var client = new HttpClient();

    // Start every request, then await them together.
    var tasks = urls.Select(async url =>
    {
        using var response = await client.GetAsync(url, cancellationToken);
        response.EnsureSuccessStatusCode();
        return await response.Content.ReadAsStringAsync(cancellationToken);
    });

    return await Task.WhenAll(tasks);
}
The cancellation token threads through every awaited call, so a timeout or a user navigating away actually stops the work rather than leaving it running. Passing tokens all the way down is the convention that makes .NET services well-behaved under load.
A minimal API in a dozen lines
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<AppDb>(o => o.UseSqlite("Data Source=app.db"));

var app = builder.Build();

app.MapGet("/books/{id:int}", async (int id, AppDb db) =>
    await db.Books.FindAsync(id) is Book book
        ? Results.Ok(book)
        : Results.NotFound());

app.MapPost("/books", async (Book book, AppDb db) =>
{
    db.Books.Add(book);
    await db.SaveChangesAsync();
    return Results.Created($"/books/{book.Id}", book);
});

app.Run();
Minimal APIs removed most of the ceremony that C# web code was known for. Dependency injection is implicit in the handler parameters — `AppDb` is resolved from the container per request.

Common pitfalls

The mistakes that cost everyone an afternoon at least once.

  • Blocking on async code

    `.Result` or `.Wait()` on a Task can deadlock in contexts with a synchronization context, and wastes a thread everywhere else. Await all the way up, or make the entry point async.

  • `async void`

    Exceptions from an `async void` method cannot be caught by the caller and will crash the process. Use `async Task` for everything except event handlers.

  • Not disposing `IDisposable`

    The garbage collector handles memory, not file handles, sockets or database connections. Use `using` declarations — leaked connections exhaust the pool and take the service down under load.

  • Struct mutation surprises

    Structs are copied on assignment and when passed, so mutating one you retrieved from a collection changes a copy. Prefer `readonly struct` unless you have a specific reason not to.

  • String concatenation in loops

    Strings are immutable, so each `+=` allocates a new one. Use `StringBuilder` for repeated appends, or `string.Join` when combining a collection.

  • Ignoring nullable warnings

    Enabling nullable reference types and then suppressing the warnings with `!` gives you the annotation burden with none of the benefit. Fix the model or annotate it honestly.

In production

Where it is running at scale, and what it is doing there.

  • Microsoft

    Windows applications, Azure services, and enterprise software.

  • Stack Overflow

    Web application backend and API services.

  • Unity Technologies

    Game development scripting and engine components.

  • Dell

    Enterprise applications and internal business systems.

Learning path

A realistic order to learn things in, with something to build at each step.

  1. 1

    Weeks 1–2

    Language fundamentals

    Types, `var`, control flow, methods, classes versus structs, collections and the difference between value and reference semantics. Use top-level statements to skip the ceremony while learning.

    Build this: Write a console application that manages a to-do list in memory.

  2. 2

    Weeks 3–4

    Object orientation and LINQ

    Interfaces, inheritance, generics, exceptions, `IEnumerable<T>`, and LINQ's core operators. LINQ repays study time faster than almost any other C# feature.

    Build this: Load a CSV into objects and answer five analytical questions using only LINQ.

  3. 3

    Weeks 5–8

    Async and the platform

    `async`/`await`, `Task`, cancellation tokens, dependency injection, configuration, and logging. Learn why blocking on `.Result` causes deadlocks before you meet one in production.

    Build this: Build a service that calls several external APIs concurrently and degrades gracefully when one fails.

  4. 4

    Months 3–4

    Build something real

    ASP.NET Core for web APIs, Entity Framework Core for data, xUnit for tests, and Blazor, MAUI or Unity depending on where you are heading.

    Build this: Ship a REST API with a database, authentication and integration tests.

  5. 5

    Ongoing

    Depth

    Nullable reference types, `Span<T>` and memory efficiency, source generators, native AOT, and profiling with dotnet-counters and dotnet-trace.

    Build this: Benchmark a hot path with BenchmarkDotNet and reduce its allocations.

Ecosystem and tooling

The tools you will end up installing whichever project you join.

ToolWhat it does
.NET SDKCompiler, runtime, project system and CLI in one install — `dotnet new`, `build`, `test`, `publish`
ASP.NET CoreThe web framework: APIs, MVC, real-time via SignalR, authentication
Entity Framework CoreThe default ORM, with LINQ queries translated to SQL and code-first migrations
NuGetPackage management, integrated into the SDK and every IDE
xUnit / NUnitUnit testing frameworks; xUnit is the common default for new projects
Visual Studio / RiderFull-featured IDEs; VS Code with the C# Dev Kit covers lighter workflows
BenchmarkDotNetRigorous micro-benchmarking that handles warm-up and statistics correctly
UnityThe game engine that made C# one of the most widely used languages in game development

C# libraries

28 catalogued, each with installation, worked examples and best practices.

Frequently asked

Is C# still tied to Windows?

No. Modern .NET runs on Linux and macOS as a first-class target, and Linux containers are a completely normal deployment. The only Windows-bound parts are the legacy .NET Framework and desktop UI frameworks such as WinForms and WPF.

C# or Java?

Technically very close, and either is a good choice. C# tends to adopt language features earlier — LINQ, async/await, records and pattern matching all arrived there first — and has a stronger story in game development via Unity. Java has a larger cross-industry footprint and more Linux-native enterprise history. In practice the decision usually follows the surrounding ecosystem and hiring pool.

What is the difference between .NET Framework and .NET?

The .NET Framework is the original Windows-only implementation, still supported but frozen at 4.8. 'NET' with a version number — .NET 8, 10 — is the modern, cross-platform, open-source, actively developed line. New projects should always target the latter.

Should I use Blazor for front-end work?

Blazor Server suits internal tools and dashboards where a persistent connection is acceptable. Blazor WebAssembly lets you write client-side code in C#, at the cost of a larger initial download than a comparable JavaScript application. For a public-facing site with tight performance budgets, an established JavaScript framework is still usually the safer choice.

How fast is C#?

Considerably faster than most people assume — commonly within a small factor of C++ for typical service workloads, and better than that when written carefully with `Span<T>` and value types. It carries a garbage collector, so it is not for hard real-time work, but throughput is not the limiting factor for the vast majority of applications.

Which version should I target?

The latest LTS release — .NET 10 — unless a dependency dictates otherwise. LTS versions receive three years of support, which matches most production lifecycles comfortably.