Getting Started

This section documents C# 14 on .NET 10 (LTS), as published at learn.microsoft.com/dotnet/csharp, which is the reference these pages are written and verified against. Features introduced by C# 15 / .NET 11 are still in preview and are always flagged as such — never presented as baseline.

This content was generated with the assistance of AI and should be verified against learn.microsoft.com before being relied on in production.

This section’s bibliography lists the reference material consulted while preparing these pages.

C# is a general-purpose, type-safe, object-oriented and functional language designed by Anders Hejlsberg at Microsoft and standardised as ECMA-334. It runs on .NET: your source is compiled by Roslyn to a portable intermediate language (IL) that a runtime then turns into native code, either just-in-time as the program runs or ahead-of-time when you publish. That combination — a high-level language with a managed runtime, a very large class library and a single cross-platform SDK — is what makes the same C# source build and run unchanged on Windows, Linux, macOS, Android, iOS and WebAssembly.

A Short History

Version Year What it introduced

C# 1.0

2002

The language itself: classes, interfaces, structs, delegates, events, properties.

C# 2.0

2005

Generics, nullable value types, iterators (yield), anonymous methods, partial types.

C# 3.0

2007

LINQ, lambda expressions, extension methods, var, anonymous types, expression trees.

C# 4.0

2010

dynamic, named and optional arguments, generic variance (in/out).

C# 5.0

2012

async/await and the task-based asynchronous pattern.

C# 6.0

2015

The Roslyn compiler, string interpolation, nameof, expression-bodied members, ?..

C# 7.x

2017-18

Tuples and deconstruction, pattern matching, local functions, ref locals/returns, in.

C# 8.0

2019

Nullable reference types, async streams, switch expressions, ranges and indices, default interface members.

C# 9.0

2020

Records, top-level statements, init-only setters, target-typed new.

C# 10

2021

File-scoped namespaces, global usings, record structs, extended property patterns.

C# 11

2022

Raw string literals, generic math (static abstract members), required members, list patterns.

C# 12

2023

Primary constructors for classes and structs, collection expressions, alias any type, inline arrays.

C# 13

2024

params collections, the new System.Threading.Lock, ref/unsafe in iterators and async, partial properties.

C# 14

2025

The field keyword, extension blocks, null-conditional assignment, user-defined compound assignment, partial constructors and events, implicit span conversions, file-based apps.

C# 14 is the version that ships with the .NET 10 SDK and is what this section documents. C# 15, paired with .NET 11, is in preview; the features it adds are covered only in clearly labelled preview subsections, and C# Versions and What’s New collects them in one place.

Where C# Is Used

  • Web and services — ASP.NET Core (minimal APIs, MVC, Razor Pages, SignalR, gRPC). This site has a whole ASP.NET Reference for that material; these pages cover the language, not the framework.

  • Web UI — Blazor, running either on the server or as WebAssembly in the browser.

  • Desktop and mobile — .NET MAUI, WPF, WinForms, Avalonia and Uno Platform.

  • Games — Unity and Godot both script in C#.

  • Cloud and data — Azure Functions, Orleans, Dapr, EF Core, ML.NET.

  • Tooling — Roslyn analyzers and source generators, dotnet global tools, MSBuild tasks.

Installing the .NET 10 SDK

The SDK contains the compiler, the CLI, the runtime and the class library. Install it once and everything else follows.

Windows

Download the installer from dotnet.microsoft.com, or use a package manager: winget install Microsoft.DotNet.SDK.10.

macOS

brew install --cask dotnet-sdk, or the .pkg installer from the same download page. Both Arm64 (Apple silicon) and x64 builds are published.

Linux

Most distributions package it directly — sudo apt install dotnet-sdk-10.0 on Ubuntu/Debian, sudo dnf install dotnet-sdk-10.0 on Fedora/RHEL. Microsoft also publishes packages and a dotnet-install script; see Install .NET on Linux.

Verify the result:

dotnet --version      # 10.0.x
dotnet --list-sdks    # every SDK installed side by side
dotnet --info         # SDK, runtimes, RID and install paths

Side-by-side installs are normal and safe: a project selects its SDK through its target framework and, if you need to pin one, a global.json file.

NET 10 is an LTS (Long Term Support) release, supported for three years. Odd-numbered releases such as .NET 9

and .NET 11 are STS releases with 18 months of support. See C# and .NET for the full support policy and how it interacts with target framework monikers.

Choosing an IDE

  • Visual Studio 2026 (Windows) — the full IDE: designers, profilers, hot reload, deep debugging.

  • Visual Studio Code + the C# Dev Kit extension — cross-platform, lightweight, the common choice on macOS and Linux.

  • JetBrains Rider — cross-platform commercial IDE with strong refactoring.

All three use the same Roslyn language service, so completions, analyzers and .editorconfig code style behave identically. Nothing in this section requires an IDE: dotnet plus a text editor is enough.

Your First Program

dotnet new console -o HelloWorld
cd HelloWorld
dotnet run

dotnet new console scaffolds two files. The project file is small because the SDK supplies the defaults:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>

Program.cs uses top-level statements — no class, no Main, just the code:

Console.WriteLine("Hello, World!");

The compiler wraps that in a synthesised entry point for you. ImplicitUsings is why Console resolves without a using System; line, and Nullable turns on nullable reference types. Both are on by default in new projects and both are assumed throughout this section.

The traditional explicit form still works and is what you will see in older code:

namespace HelloWorld;

internal class Program
{
    private static void Main(string[] args)
    {
        Console.WriteLine("Hello, World!");
    }
}

A program may have top-level statements in one file only, and cannot combine them with an explicit Main in the same project.

From C# source to native code: Program.cs is compiled by the Roslyn compiler into an assembly containing IL plus metadata; at run time the CLR either JIT-compiles the IL to native code method by method

File-Based Apps (C# 14)

C# 14 and the .NET 10 SDK let you run a single .cs file with no project at all — ideal for scripts, learning and reproducing a bug report:

dotnet run hello.cs

Such a file may carry file-level directives that replace what a .csproj would otherwise say:

#!/usr/bin/env dotnet
#:sdk Microsoft.NET.Sdk
#:package Humanizer@2.14.1
#:property LangVersion=latest

Console.WriteLine("Runs straight from a single file.");

:package adds a NuGet reference, :sdk selects the SDK, and :property sets any MSBuild property. On Unix-like systems the ! shebang plus chmod +x makes the file directly executable. When a script outgrows this format, dotnet project convert hello.cs turns it into a normal project.

These directives are covered in full in Preprocessor Directives and Compilation.

The Everyday CLI Commands

dotnet new console -o MyApp     # scaffold a project (see `dotnet new list` for templates)
dotnet build                    # compile
dotnet run                      # build and run
dotnet watch                    # rebuild and rerun on every save
dotnet test                     # run the test projects
dotnet publish -c Release       # produce a deployable output
dotnet format                   # apply .editorconfig code style

Build and Tooling covers these in depth.

C# for Java Developers

If you are coming from Java — this site’s Java Reference is the companion section — most of your instincts transfer, with these differences worth knowing on day one:

Java C# Note

package

namespace

Namespaces need not match the folder layout, and are ;-terminated (file-scoped) in modern code.

import

using

Also using static, global using and alias form. See Lexical Structure and Style.

final

readonly / const / sealed

Three distinct concepts rather than one keyword.

Getters and setters

Properties

First-class language feature, not a naming convention.

Erased generics

Reified generics

List<int> really is a distinct type at run time, with no boxing. See Generics.

Checked exceptions

None

See Exceptions and Error Handling.

Streams

LINQ

See LINQ.

record

record

Very similar, but C# adds with expressions and record structs.

Everything is a reference type

struct is a real value type

See Structs and Value Types.

See Also

  • C# and .NET — the runtime, the class library and the release cadence behind the language.

  • Lexical Structure and Style — the spelling rules and the conventions this section follows.

  • Build and Tooling — the dotnet CLI, MSBuild and the debugging and diagnostics tools.

  • ASP.NET Reference — for web applications and services built on this language.