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 C# lambda expression with a default value assigned to a parameter, highlighting C# 12 syntax.
C#

C# Lambda Default Parameters: Syntax and Limits

Learn how to use default values in C# lambda expressions: C# 12 syntax, compile-time rules, call-site behavior, and workarounds for older versions.

C#LambdaDefault ParametersC# 12
Diagram illustrating C# primary constructor class syntax with parameters and class body.
C#

C# Primary Constructors for Classes: Syntax and Usage

C# primary constructors for classes: syntax, parameter capture, dependency injection examples, and the limits to check before replacing a constructor.

C#Primary ConstructorsClass DesignDependency Injection
Illustration of C# reflection retrieving attributes from a class member
C#

C# Reflection: Get Attributes from Types and Members

Learn how to use C# reflection to retrieve custom attributes from types and members, including inheritance behavior and performance considerations.

ReflectionAttributesC#Metadata
Illustration of sorting elements using a custom IComparer in C#
C#

C# IComparer: Custom Sorting with IComparer<T>

Learn IComparer<T> in C# with a working example: custom sort order for Array.Sort and List<T>.Sort, null-safe Compare rules, and reuse tips.

IComparerC# SortingComparison<T>Custom Comparer
Diagram showing the relationship between async, await, and Task in C#
C#

C# async/await and Task Relationship Explained

Understand how C# async, await, and Task fit together: how async methods return Task, when await suspends execution, and how exceptions propagate across the task boundary.

asyncawaitTaskasynchronous programming
Comparison of Object.Equals and ReferenceEquals in C# showing two objects with same value but different references.
C#

C# Object.Equals vs ReferenceEquals: Key Differences

Object.Equals and ReferenceEquals answer different questions in C#: value equality vs reference identity. Learn how each works, when to override Equals, and common pitfalls.

C#Object.EqualsReferenceEqualsvalue equality
Illustration comparing the == operator and Equals method for string comparison in C#.
C#

C# String Equals vs ==: What’s the Difference?

Understand the difference between == and Equals when comparing strings in C#, including reference equality, interning, and culture-sensitive comparisons.

C#String ComparisonEquality.NET
Comparison of List.Find and LINQ First in C# showing search behavior and default values.
C#

C# List Find vs LINQ First: Which to Use

Compare List<T>.Find with LINQ First and FirstOrDefault in C#: syntax, behavior, performance, and when to use each.

C#LINQList<T>FirstOrDefault
Illustration comparing C# List Find and LINQ Where methods, showing a single element versus multiple elements
C#

C# Where vs Find: Choosing the Right Approach

Understand the differences between Where and Find in C#, including when each is appropriate for collection searches and how their behavior affects performance.

LINQList<T>ArrayPerformance
Diagram showing a collection of nested arrays being flattened into a single sequence, contrasting Select and SelectMany in C#.
C#

C# Select vs SelectMany: Key Differences

Understand the difference between C# LINQ Select and SelectMany. See code examples for one-to-one projection, flattening nested collections, and when to choose each method.

LINQC#SelectSelectMany