Pages

Topics

Tools

↑↓navigate↵openescclose

C# guides

Every published C# guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest C# guides

Illustration of a C# task completing and returning a value, showing the flow from asynchronous operation to a finished result.
C#

C# Task Return Value: Using Task<TResult>

c# task return value: Learn how to return values from C# tasks using Task<TResult>, including declaration, creation, awaiting, exception handling, and performance trad...

Task<TResult>async/awaitValueTaskTaskCompletionSource
Illustration of a C# Task<T> generic type representing an asynchronous operation that returns a value.
C#

C# Task<T>: Returning Values from Async Methods

Learn how Task<T> works in C#, how to return values from async methods, and when to use it instead of plain Task.

C#Task<T>async/awaitTPL
A stylized C# Task icon representing asynchronous operations, with a checkmark and a clock to indicate completion and timing.
C#

Understanding C# Task and Async Programming

Learn how C# Task works, how to create and await tasks, handle errors and cancellation, and choose between Task and ValueTask for performance.

async/awaitTaskconcurrencyasynchronous programming
Illustration of a C# await keyword suspending a method and resuming later on a different thread
C#

C# await Keyword: Async Method Behavior

Understand how the C# await keyword suspends async methods, returns control to callers, and handles exceptions in async programming.

async programmingTaskasync/awaitC# concurrency
Illustration of a C# async method using await to offload work to a background task while the caller continues.
C#

C# Async Method: How async and await Work

Learn how async and await work in C#: return types, exception handling, cancellation, performance tradeoffs, and common pitfalls.

async/awaitTaskasynchronous programmingC# concurrency
Diagram of an async method state machine showing await points and thread yield to the thread pool.
C#

C# Async Await: Execution, Pitfalls, and Best Practices

Understand how C# async and await work under the hood, write correct async methods, and avoid deadlocks and performance traps.

async/awaitTask-based Asynchronous PatternC# ConcurrencyCancellationToken
Diagram showing object initialization with indexer assignment in C#.
C#

C# Index Initializer: Syntax and Usage

c# index initializer: Learn how to use index initializers in C# to set indexer values during object creation, with syntax examples and practical usage patterns.

C#Index InitializerObject InitializerIndexer
Diagram showing nested object initializer syntax in C# with braces and property assignments.
C#

C# Nested Object Initializer Syntax and Behavior

Learn how C# nested object initializers work, including the assignment and nested-member forms, collection initialization, common mistakes, and tradeoffs.

C#Object InitializerNested ObjectsCollection Initializer
Illustration comparing C# anonymous type and record data structures with a balance scale and code blocks.
C#

C# Anonymous Type vs Record: Practical Comparison

Compare C# anonymous types and records on syntax, equality, immutability, and when to choose each for data modeling.

C#anonymous typesrecordsdata modeling
Illustration of C# anonymous type properties showing a compiler-generated type with read-only properties.
C#

C# Anonymous Type Properties: Syntax and Behavior

C# anonymous type properties: Learn how to declare them, their read-only behavior, equality semantics, LINQ usage, and practical limitations.

C#Anonymous TypesLINQType System