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# List showing Count as the number of filled slots and Capacity as the total allocated slots.
C#

C# List Count vs Capacity: Key Differences

Understand the difference between Count and Capacity in C# List<T>, and see how setting Capacity can affect memory usage and performance.

C#List<T>performancememory management
Diagram comparing the Count property on a C# List<T> with the LINQ Count() extension method, showing how both return the number of elements.
C#

C# List Count: Count Property vs Count() Method

Compare the List<T>.Count property and the LINQ Count() method: how they behave on List<T>, performance traits, and when to use Count() over Count.

C#List<T>LINQ.NET Collections
Illustration of a C# foreach loop iterating over a list with an enumerator pointer.
C#

C# List foreach: Syntax, Pitfalls, and Performance

Learn how to use foreach with List<T> in C#, including syntax, enumerator behavior, common pitfalls, and performance tradeoffs.

C#ListforeachIEnumerable
Illustration of reversing the order of elements in a C# List, showing in-place and LINQ approaches.
C#

How to Reverse a List in C#: In-Place and LINQ

Reverse a C# List<T> with List.Reverse() or LINQ's Reverse(). Compare in-place mutation, deferred enumeration, and practical tradeoffs.

C#ListLINQCollections
Visual metaphor of a C# List being sorted, showing an unordered list transforming into an ordered sequence with arrows.
C#

C# List Sort: List.Sort vs LINQ OrderBy

Learn how to sort a List<T> in C# using List.Sort and LINQ OrderBy, including custom comparers, multiple-key sorting, and performance tradeoffs.

C#List<T>SortingLINQ
Illustration of a C# List with a magnifying glass checking for an element, representing existence checks.
C#

C# List Exists: How to Check for Elements

Learn how to check whether an item exists in a C# List using Contains, Exists, and LINQ Any, including equality and performance behavior.

C#ListLINQContains
Illustration of a C# list with an index pointer highlighting a matching element using FindIndex.
C#

C# List FindIndex: Locating Elements by Predicate

Learn how to use `List<T>.FindIndex` in C# to locate the first element matching a predicate, handle `-1` when nothing matches, and choose among `FindIndex`, `IndexOf`, and LINQ.

C#List<T>FindIndexPredicate
Illustration of a C# list being filtered by a predicate, showing matching items selected into a new list.
C#

Using C# List FindAll to Filter Collections

Learn how to filter a List<T> with FindAll and Predicate<T> in C#, including syntax, examples, and how it compares with LINQ Where.

C#List<T>PredicateFiltering
Illustration of searching a C# list with a predicate to find a matching element.
C#

C# List Find: Using Predicates to Locate Elements

Learn how to use C# List<T>.Find with predicates, handle missing elements, and decide when to prefer LINQ alternatives.

C#List<T>PredicateLINQ
Illustration of a C# List with an index pointer highlighting the position of a found element.
C#

C# List IndexOf: Locating Elements in a List

Learn how to use List.IndexOf in C# to find element positions, handle missing items, and choose between IndexOf and FindIndex.

C#List<T>IndexOfCollections