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

Two overlapping collection symbols meeting on a key, representing the C# LINQ Join operation.
C#

Understanding C# LINQ Join with Examples

c# linq join: Learn how to use LINQ Join to combine collections, including inner, left, and multi-key joins, with C# examples and common pitfalls.

LINQC#SQL JoinIEnumerable
Diagram showing collection elements being grouped into subsets based on a key selector in C# LINQ.
C#

C# LINQ GroupBy: Grouping Data Correctly

Practical C# LINQ GroupBy examples for single and composite keys, deferred execution, and performance trade-offs.

LINQGroupByC# CollectionsData Aggregation
Code snippet showing LINQ DistinctBy with a key selector that filters duplicate objects based on a single property
C#

How to Use LINQ DistinctBy in C#

Learn how to use LINQ DistinctBy in C# to remove duplicate objects based on a specific property, with practical examples, custom comparers, and performance tradeoffs.

LINQDistinctDistinctByC#
Illustration of C# LINQ Distinct removing duplicate elements from a sequence, with a set icon and code-like shapes
C#

Using C# LINQ Distinct Effectively

c# linq distinct: Learn how C# LINQ Distinct works, when it uses default equality, and how to customize it with a comparer for reference types and complex objects.

LINQC#IEqualityComparerSequence Operations
Illustration of a bar chart with the shortest and tallest bars highlighted, representing LINQ Min and Max operations on a sequence.
C#

Using Min and Max in C# LINQ

Learn how to use LINQ Min and Max in C#: basic syntax, selector projections, empty sequence exceptions, nullable handling, and performance tradeoffs.

LINQIEnumerableSequence OperationsNull Handling
Illustration of a C# LINQ Average operation aggregating a sequence of numeric blocks into a single mean value.
C#

C# LINQ Average: Syntax and Edge Cases

Learn how to use LINQ's Average method in C#: syntax, numeric type behavior, empty sequence handling, selector projections, and performance considerations.

LINQC#.NETEnumerable
Illustration of a C# LINQ Sum operation showing a collection of numbers being totaled into a single result.
C#

C# LINQ Sum: Syntax, Edge Cases, and Performance

Learn how to use the C# LINQ Sum method with code examples, including selector overloads, empty and nullable sequences, and when to choose Aggregate.

C#LINQSumAggregate
Illustration of a C# LINQ LongCount operation counting elements in a large collection with a long return type.
C#

C# LINQ LongCount: When to Use It

c# linq longcount: Learn when and how to use LongCount in C# LINQ to avoid overflow when counting large collections, and how it differs from Count.

LINQC# performancecounting elementslong return type
Illustration of counting elements in a C# collection using LINQ Count method.
C#

C# LINQ Count: Syntax, Predicates, and Performance

c# linq count: Learn how to use the LINQ Count method in C#: basic syntax, predicate overloads, LongCount, and performance considerations for large collections.

LINQCountIEnumerablePerformance
Illustration of a magnifying glass examining a collection of cubes, with one cube highlighted, representing the C# LINQ Contains method checking for element membership.
C#

C# LINQ Contains: Usage, Performance, and Pitfalls

Understand how C# LINQ Contains determines membership, when to use a custom equality comparer, and how performance differs between List and HashSet.

LINQC#HashSetEntity Framework