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 two object references pointing to the same memory location, illustrating ReferenceEquals in C#.
C#

C# ReferenceEquals: When to Use It and How It Works

Learn how ReferenceEquals compares object identity in C#, how boxing affects value types, and when to use it instead of == or Equals.

ReferenceEquals
A visual comparison of the C# equality operator and Equals method showing reference versus value equality
C#

C# == vs Equals: How They Differ and When to Use Each

Learn how the C# == operator and Equals method differ for reference types, value types, and strings, and when to override or overload them.

C#EqualityOperator OverloadingValue Types
Diagram showing two object boxes with an equals sign, one pair identical, the other different, illustrating C# equality comparison.
C#

C# Equality Comparison: Value vs. Reference Types

Learn how C# equality comparison works for value and reference types, including Equals, GetHashCode, operator overloading, IEquatable<T>, and records.

C# EqualityValue TypesReference TypesIEquatable<T>
C# code showing the discarded underscore character being used to ignore an out parameter, with a visual emphasis on the underscore symbol.
C#

Using the C# Discard Operator Effectively

Learn how to use the C# discard (`_`) to ignore unwanted values in assignments, out parameters, tuple deconstruction, and pattern matching, with practical examples.

C#discard operatortuple deconstructionpattern matching
Illustration of a C# object splitting into multiple variables through a Deconstruct method.
C#

C# Deconstruct Method: Syntax and Use Cases

Learn how to implement and use the C# Deconstruct method to unpack objects and tuples into individual variables, including syntax, overloads, pattern matching, extension methods, and common pitfalls.

DeconstructionC# SyntaxTuplesPattern Matching
Illustration of nested boxes representing recursive pattern matching in C#
C#

C# Recursive Pattern Matching Explained

Learn how recursive patterns in C# simplify complex data inspections with nested positional and property patterns, switch expressions, and pattern combinators.

C# pattern matchingrecursive patternspositional patternsproperty patterns
C# code with is pattern matching syntax, featuring a highlighted is expression and property pattern with visual cues of type checking
C#

C# Is Pattern Matching: Syntax and Use

c# is pattern matching: Learn how the `is` pattern in C# works, from type checks to property and relational patterns, with practical code examples and performance insi...

pattern matchingC# syntaxswitch expressionsproperty patterns
Illustration of a C# list pattern matching a collection of elements with brackets and a slice operator.
C#

C# List Pattern: Match Collections with Concise Syntax

c# list pattern: Understand C# list patterns, a concise way to match collection length and elements in pattern matching contexts.

C#Pattern MatchingList Patterns.NET
Illustration of a C# positional pattern matching an object by deconstructing it into parts, with a switch expression in the background.
C#

C# Positional Pattern: Matching Objects by Shape

Learn how the C# positional pattern uses deconstruction to match objects by shape, with practical switch-expression examples and common pitfalls.

C#Pattern MatchingSwitch ExpressionsDeconstruction
C# property pattern diagram showing an object being matched against property conditions with arrows pointing to match branches
C#

C# Property Pattern with Examples

Learn how to use the C# property pattern to match objects based on their properties, with practical examples and common pitfalls.

Pattern MatchingC# SyntaxProperty ValidationSwitch Expressions