Browse by Topic
Popular
Popular Posts
Latest
Latest Posts
C# Custom Sorting with Comparers and LINQ
Learn how to implement custom sorting in C# with IComparer, Comparison delegates, and LINQ OrderBy, including practical examples and performance considerations.
Creating Custom Comparers in C# for Sorting and Equality
Learn how to create custom comparers in C# to control sorting and equality in LINQ, collections, and dictionaries.
Implementing IEquatable<T> in C# for Efficient Equality Checks
Implement IEquatable<T> in C# to define typed equality checks, avoid boxing for structs, and keep hash-based collections consistent. Includes examples for value types and reference types, plus common pitfalls.
C# GetHashCode: Contract and Correct Overrides
Learn how GetHashCode works in C#, why it matters for Dictionary and HashSet, and how to override it correctly alongside Equals.
Understanding C# Object Equals: Reference vs Value Equality
Learn how object.Equals works in C#, when to override it, and how to implement value equality correctly with GetHashCode and IEquatable<T>.
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.
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# 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.
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# 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.