All syntax guides
Short, practical guides on programming syntax, language fundamentals, and the tools developers reach for every day.
3,965 guides across 14 topics
Topics
Popular guides
Most readLatest guides
Page 342 of 397C# Boxing vs Unboxing: How They Affect Performance
Understand how C# boxing and unboxing work, why boxing can add allocations, and how to reduce unnecessary conversions in performance-sensitive code.
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.