Browse by Topic

Popular

Latest

Latest Posts

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
Diagram showing two boxes labeled A and B with an arrow indicating a copy of a struct value from A to B, emphasizing independent copies.
C#

Understanding C# Struct Value Type Behavior

See how C# structs copy on assignment and method calls, where mutation of structs in collections can fail, and when value type behavior matters for performance.

C#value typesstructsperformance
Diagram illustrating a struct being copied by value into a new memory location in C#.
C#

C# Struct Copy Behavior: Value Type Semantics Explained

Understand how C# structs are copied by value, why it matters for performance and correctness, and how to control copy behavior with ref, readonly, and in parameters.

C# structsvalue typescopy semanticsperformance
Diagram showing a record struct value being copied between two variables, illustrating value semantics.
C#

C# record struct: Value Semantics with Record Features

Record structs combine C# value-type semantics with record syntax. See how positional declarations, value equality, mutation, readonly variants, and performance tradeoffs work, and when to choose one over a record class or plain struct.

record structC# 10value typesvalue equality
Illustration of a C# ref struct as a stack-only value type with Span<T> referencing contiguous memory.
C#

C# ref struct: Constraints and Practical Use

Learn how C# ref struct types enforce stack-only allocation, what compiler restrictions they carry, and how Span<T> uses them for safe, allocation-free memory access.

ref structSpan<T>stackallocvalue types
Diagram showing a readonly struct preventing defensive copies in C#
C#

C# Readonly Struct: When and How to Use

c# readonly struct: Learn how C# readonly structs prevent defensive copies, enforce immutability, and when they improve performance.

C#structsimmutabilityvalue types
Diagram showing a C# struct value on the stack with a constructor assigning its fields, illustrating value-type initialization.
C#

C# Struct Constructor: Rules and C# 10 Changes

c# struct constructor: Learn C# struct constructor rules: parameterized constructors, implicit parameterless initialization, C# 10 field initializers, and performance.

C#structconstructorsvalue types
Diagram comparing a struct's value copy on assignment with a class's shared reference, illustrating C# value and reference type behavior.
C#

C# Struct vs Class: Choosing the Right Type

c# struct vs class: Understand the differences between C# structs and classes: value vs reference semantics, memory allocation, performance tradeoffs, and when to choo...

C#structclassvalue types