C# Reference ยท .NET, Tools and Concepts
C# and .NET versions
Which C# version ships with which .NET release, what each version added from C# 1 to C# 14, how the default language version is chosen and what LTS means.
C# and .NET are versioned separately but released together. C# is the language, and its compiler (Roslyn) turns your source into intermediate language. .NET is the platform: the runtime, the base class library and the SDK tools. Each .NET release comes with one new C# version, shipped every November, and since .NET 5 both use a single yearly number scheme: .NET 10 goes with C# 14.
You almost never choose a language version by hand. The SDK picks a default from your target framework, so a project that targets net10.0 compiles as C# 14 and one that targets net8.0 compiles as C# 12. This is why a new language feature sometimes "does not exist" after you copy code into an older project.
<PropertyGroup> <TargetFramework>net10.0</TargetFramework> <!-- LangVersion is optional; the default for net10.0 is 14 --> <LangVersion>latest</LangVersion> </PropertyGroup>
Try it
Every C# version added something you can still use today. This program touches one feature from many versions. It compiles only with a modern compiler, because it needs everything from C# 6 up to C# 13.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with Console.ReadLine()), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with Console.ReadLine()), it gets the next line from this box.
Version timeline
| C# | .NET | Year | Headline features |
|---|---|---|---|
| 1.0 | .NET Framework 1.0 | 2002 | Classes, interfaces, delegates, events, properties |
| 2.0 | Framework 2.0 | 2005 | Generics, nullable value types, iterators (yield), anonymous methods, partial classes |
| 3.0 | Framework 3.5 | 2007 | LINQ, lambdas, extension methods, var, object and collection initializers, anonymous types |
| 4.0 | Framework 4.0 | 2010 | Named and optional arguments, dynamic, covariance and contravariance |
| 5.0 | Framework 4.5 | 2012 | async and await, caller info attributes |
| 6.0 | Framework 4.6 | 2015 | Roslyn compiler, ?., nameof, string interpolation, expression-bodied members |
| 7.0 to 7.3 | Framework 4.7, .NET Core 2.x | 2017 | Tuples, out var, pattern matching, local functions, ref returns, Span<T> support |
| 8.0 | .NET Core 3.0 | 2019 | Nullable reference types, ranges and indices, switch expressions, async streams, default interface members |
| 9.0 | .NET 5 | 2020 | Records, init accessors, top-level statements, target-typed new |
| 10 | .NET 6 | 2021 | Global usings, file-scoped namespaces, record structs, constant interpolated strings |
| 11 | .NET 7 | 2022 | Raw string literals, list patterns, required members, generic math, file types |
| 12 | .NET 8 | 2023 | Primary constructors, collection expressions, alias any type, inline arrays |
| 13 | .NET 9 | 2024 | params collections, System.Threading.Lock, \e escape, partial properties |
| 14 | .NET 10 | 2025 | Extension members, field keyword, null-conditional assignment, implicit span conversions |
C# 7 had point releases (7.1 to 7.3) between .NET Core versions. From C# 8 on, the language gets one release per year, tied to the .NET release.
Syntax
Choosing the language version
The LangVersion property in the project file (or -langversion on the compiler command line) overrides the default.
| Value | Meaning |
|---|---|
default |
The default for the target framework (the normal choice) |
latest |
The newest released version the installed compiler supports |
latestMajor |
Same as latest for current compilers |
preview |
The newest version including features still in preview |
12, 13, 14 |
A specific version |
Setting LangVersion higher than the default can work for language-only features, but features that need new runtime types (for example System.Threading.Lock in C# 13) still need a runtime that has those types.
Targeting and support
| Term | Meaning |
|---|---|
| LTS (long-term support) | Even-numbered releases such as .NET 6, 8 and 10. Supported for three years. Best for production. |
| STS (standard-term support) | Odd-numbered releases such as .NET 7 and 9. Supported for a shorter period (two years since 2025). |
TargetFramework |
net10.0, net8.0, netstandard2.0 (a shared API surface for libraries), net48 (.NET Framework) |
Usage notes
- The language and the runtime can differ. Most C# features are compiler-only (the compiler rewrites them into older constructs), so they work on old runtimes. A few need new runtime support: static abstract interface members (C# 11), ref fields (C# 11) and default interface members (C# 8).
- Old target frameworks cap the default version.
netstandard2.0andnet48default to C# 7.3. You can raiseLangVersion, but features such as records need extra types (IsExternalInit) that you must define yourself. - Each new C# version is source-compatible in practice, but a handful of changes alter behavior: for example C# 8 made
?on a reference type mean "nullable annotation", and C# 14 madefielda keyword inside property accessors. - Preview features need
<LangVersion>preview</LangVersion>and may change or vanish before release. Do not ship libraries that depend on them. - Pick LTS for production, and move on a schedule, so security updates keep arriving.
Environment.Versionreports the runtime version at run time. It does not tell you the C# version, which is a compile-time property.