Browse by Topic

Popular

Latest

Latest C# Posts

Diagram showing C# tuple declaration with named members and deconstruction.
C#

C# Tuple Declaration: Syntax and Usage

c# tuple declaration: Learn C# tuple declaration syntax, named members, deconstruction, and when to use ValueTuple over custom types.

C# tuplesValueTupletuple syntaxdeconstruction
Diagram showing two distinct values being grouped into a single tuple container with named member labels
C#

C# Tuple Usage: Syntax, Deconstruction, and Tradeoffs

c# tuple usage: Practical C# tuple usage: declaration syntax, named members, deconstruction, method returns, and when a tuple beats a custom type.

C#ValueTupletuple deconstructionnamed members
Diagram showing a C# positional record declaration and its generated properties and equality behavior.
C#

C# Positional Record: Syntax and Behavior

C# positional records provide a concise syntax for immutable data models. Learn how the compiler generates properties, value equality, deconstruction, and when to prefer records over classes.

C#recordspositional recordsvalue equality
Illustration of a C# record being split into separate variables, representing deconstruction.
C#

C# Record Deconstruct: Extract Fields Cleanly

Learn how C# record deconstruction extracts fields into variables. Includes positional records, custom Deconstruct methods, discards, pattern matching, and common pitfalls.

C#RecordsDeconstructionSyntax
Two identical record boxes being compared with a checkmark, symbolizing value-based equality in C#.
C#

C# Record Equality: How It Works and When to Customize

Understand how C# records implement value-based equality, when the default behavior is sufficient, and when to override Equals and GetHashCode for collections or custom rules.

C# recordsvalue equalityGetHashCodeEqualityContract
Diagram showing a C# record being copied with a with expression to create a modified instance
C#

C# Record with Expression: Copy and Modify Records

Learn how to use C# with expressions to create modified copies of immutable records, with practical examples and limitations.

C#RecordsImmutabilityWith Expression
Illustration of a C# record constructor showing generated code and init-only properties
C#

C# Record Constructor: Syntax and Customization

C# record constructors: how positional parameters generate a primary constructor, when to replace it, validation, record structs, and the copy constructor used by with expressions.

C# RecordsPrimary ConstructorsRecord StructsInit-only Properties
Diagram comparing C# record and struct types, showing value vs reference behavior and equality semantics.
C#

C# Record vs Struct: Choosing the Right Type

Learn the practical differences between C# records and structs: reference vs value semantics, equality, immutability, performance, and when to choose each.

C# recordsC# structsvalue typesreference types
A visual comparison between a C# record and a class, showing value equality versus reference equality
C#

C# Record vs Class: Choosing the Right Type

Learn the key differences between C# records and classes, including equality, immutability, and when to use each type in your code.

C#recordsclassesvalue equality
Illustration of two C# record instances compared by value, showing equality and immutable data.
C#

C# Record Usage: Syntax, Equality, and Tradeoffs

Understand C# records: declaration syntax, value equality, with-expressions, inheritance, and when records fit better than classes or structs.

C#recordsvalue equalitywith-expressions