C# Cheat Sheet
|
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. |
A single-page, colour-coded summary of the C# essentials — the program and type shapes, built-in types and
literals, string interpolation and raw string literals, the operator table with ??, ?., ^, .., is and
switch, control-flow one-liners, method parameters (ref/out/in/params), class, struct, record,
interface and enum skeletons, properties with init, required and the C# 14 field keyword, primary
constructors, generics and their constraints, every pattern-matching form, delegates, lambdas and events,
extension members, LINQ in both query and method syntax with the most-used operators, collection expressions and
the common collections, nullable annotations, exceptions and guard helpers, using/IDisposable,
async/await idioms, lock/Interlocked/Parallel, Span<T> and stackalloc, attributes and reflection
one-liners, the dotnet CLI and the .csproj essentials, xUnit facts and theories, and the naming conventions — handy for quick memorization or as a printable desk reference.
Features added in C# 12, 13 and 14 are marked with their version on the sheet, so it doubles as an upgrade checklist.
For the full explanation, every option, and additional examples, see the dedicated pages:
Getting started — Getting Started, C# and .NET, Lexical Structure and Style, Basic Types and Variables, Strings and Text, Operators and Expressions, Control Flow, and Methods and Parameters.
Types and object-oriented programming — Classes and Objects, Structs and Value Types, Inheritance and Polymorphism, Interfaces, Records, Enums, Generics, Tuples, Deconstruction and Anonymous Types, Nullable Types and Null Safety, Equality and Operator Overloading, and Extension Members.
Functional programming — Delegates, Lambdas and Events, Pattern Matching, Collections and Iterators, LINQ, and Expression Trees and Dynamic.
Error handling and resources — Exceptions and Error Handling and Memory Management and Disposal.
Concurrency and asynchrony — Async and Await and Threads and Synchronization.
Advanced language features — Attributes and Reflection, Unsafe Code, Spans and Performance, Native Interop, and Preprocessor Directives and Compilation.
Code organisation and tooling — Namespaces, Assemblies and Projects, Coding Conventions and Documentation, Build and Tooling, Testing, and C# Versions and What’s New.