Browse by Topic

Popular

Latest

Latest Posts

Illustration of two C# objects being compared with an ordering arrow, representing the IComparable comparison contract
C#

Implementing IComparable in C# for Reliable Sorting

c# icomparable: Learn how to implement IComparable<T> in C# for custom sorting, including CompareTo semantics, null handling, and consistency with Equals.

C#IComparableCompareToSorting
A C# code snippet showing a class implementing IComparable<T> with a sorting arrow icon in the background.
C#

C# Comparable: Implementing IComparable for Sorting

Learn how to implement IComparable<T> in C# to sort custom objects with List.Sort and Array.Sort, including null handling and common edge cases.

IComparableC# SortingCompareToIComparer
Illustration comparing two C# objects with value equality versus reference equality, showing records and classes.
C#

C# Record Equality vs Class Equality Explained

C# records and classes differ in equality behavior. Learn how value semantics work, when reference equality still matters, and how to customize record equality.

C#RecordsEqualityIEquatable
Two overlapping object diagrams with a comparison symbol, illustrating reference equality versus value equality in C#.
C#

C# Reference Equality vs Value Equality

c# reference equality vs value equality: Understand the difference between reference equality and value equality in C#, how to implement custom equality, and when reco...

EqualityIEquatableRecordsStructs
Diagram showing two objects being compared by a custom C# equality comparer with hash and equality checks.
C#

C# Equality Comparer: Implementing IEqualityComparer<T>

Learn how to implement a C# equality comparer with IEqualityComparer<T> for LINQ and Dictionary, including GetHashCode rules and performance considerations.

IEqualityComparerLINQGetHashCodeDictionary
A visual representation of the C# discard pattern showing an underscore placeholder ignoring an unused value in a code context.
C#

C# Discard Pattern: Syntax and Practical Use Cases

Learn how to use C# discards with out parameters, deconstruction, and pattern matching, plus common pitfalls to avoid.

C#DiscardPattern MatchingDeconstruction
C# var pattern illustration showing a variable assignment in a pattern matching context.
C#

C# var Pattern: Syntax, Use Cases, and Pitfalls

c# var pattern: Learn how the C# var pattern works, where it fits in pattern matching, and when it's useful versus other patterns.

C#pattern matchingvar patternswitch expressions
Illustration of a C# iterator deferring execution until enumeration, showing a lazy sequence.
C#

C# Iterator Deferred Execution

In C#, iterator methods that use yield return defer execution until enumeration. This article covers state-machine behavior, exception timing, side effects, and when to materialize a sequence.

C#iteratorsdeferred executionyield return
A diagram showing a foreach loop connecting to an IEnumerator interface with MoveNext and Current, symbolizing iteration in C#.
C#

Understanding IEnumerator in C#

c# ienumerator: Learn how IEnumerator powers foreach in C#, how to implement custom enumerators manually or with yield, and the performance tradeoffs to consider.

IEnumeratorIEnumerableforeachyield return
Illustration of C# IEnumerable representing a lazy sequence with deferred execution.
C#

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

C# IEnumerable: Learn how IEnumerable<T> works, including deferred execution, yield return, and when to choose it over List or IQueryable.

C#IEnumerableLINQDeferred Execution