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

Diagram showing a nullable value type and a nullable reference type with null checks and operators in C#.
C#

C# Nullable Usage: Value Types and Reference Types

Learn how to use nullable value types and nullable reference types in C#, including null checks, operators, and API boundary annotations.

nullable value typesnullable reference typesC# null handlingnull-coalescing operator
Illustration of a C# object being split into multiple variables, representing deconstruction.
C#

C# Deconstruction: Syntax, Custom Types, and Pitfalls

c# deconstruction: Learn how to use C# deconstruction with tuples and custom types, including the Deconstruct method, discards, and common pitfalls.

C#DeconstructionTuplesPattern Matching
Editorial illustration of the C# discard underscore: a value flows into an underscore symbol and is dropped while the surrounding code continues.
C#

C# Discard Underscore: Syntax and Practical Usage

c# discard underscore: Explains how the C# discard underscore works in out arguments, pattern matching, deconstruction, and lambdas, with scope and allocation notes.

C#discardspattern matchingdeconstruction
Editorial illustration contrasting a lightweight value tuple box with a structured class object containing methods.
C#

C# Tuple vs Class: Choosing the Right Data Carrier

Compare C# tuples and classes for carrying data: type identity, allocation, equality, and when each fits your code.

C#ValueTupleType Design.NET
Illustration comparing C# Tuple and ValueTuple showing a reference type box and a value type struct.
C#

C# Tuple vs ValueTuple: Which One Should You Use?

Understand the differences between C# Tuple and ValueTuple, including memory behavior, syntax, and when to choose each for returning multiple values.

C#ValueTupleTupleC# 7
C# tuple deconstruction concept showing a tuple being split into separate variables
C#

C# Tuple Deconstruction: Syntax and Practical Use

c# tuple deconstruction: Learn C# tuple deconstruction to unpack tuple values into variables, including discards, custom types, and practical patterns.

C#TuplesDeconstruction.NET
Conceptual illustration of a C# named tuple with labeled fields and a value type container.
C#

C# Named Tuples: Syntax and Practical Usage

Learn how to declare, access, and return C# named tuples, and understand when they are a better choice than anonymous types.

C#Named TuplesTuplesDeconstruction
A C# method returning a tuple with two named values, illustrating multiple return values.
C#

C# Tuple Multiple Return Values: Syntax and Usage

Learn how to use C# tuples to return multiple values from methods. This guide covers tuple syntax, named elements, deconstruction, ValueTuple performance tradeoffs, and when to choose a custom class or record instead.

C#TuplesValueTupleMethod Returns
Diagram showing C# tuple declaration with named members and deconstruction.
C#

C# Tuple Declaration: Syntax and Usage

c# tuple declaration: Learn C# tuple declaration syntax, named members, deconstruction, and when to use ValueTuple over custom types.

C# tuplesValueTupletuple syntaxdeconstruction
Diagram showing two distinct values being grouped into a single tuple container with named member labels
C#

C# Tuple Usage: Syntax, Deconstruction, and Tradeoffs

c# tuple usage: Practical C# tuple usage: declaration syntax, named members, deconstruction, method returns, and when a tuple beats a custom type.

C#ValueTupletuple deconstructionnamed members