Browse by Topic

Popular

Latest

Latest Posts

Diagram showing two arrows pointing to the same memory location, representing the C# ref keyword passing a variable by reference
C#

c# ref Keyword: Passing Arguments by Reference

Learn how the c# ref keyword passes arguments by reference, how it differs from out and in, and when to use it for mutation or performance.

C#ref keywordmethod parametersvalue types
Diagram showing a C# record object being copied via a with expression, highlighting the copied fields.
C#

C# Record with Object Copy: Using `with`

c# record with object copy: Learn how to copy C# record objects using `with` expressions, understand shallow vs deep copy behavior, and know when to use them.

C#RecordsObject CopyWith Expressions
Diagram showing two objects sharing references versus independent copies in C#
C#

C# Object Copying: Shallow vs Deep Copy

Learn how to copy objects in C# correctly. Compare shallow and deep copy approaches, understand reference semantics, and choose the right strategy.

C#Object CopyingDeep CopyShallow Copy
Diagram illustrating shallow copy vs deep copy in C# with MemberwiseClone
C#

C# MemberwiseClone: Shallow Copy Basics

Learn how C# MemberwiseClone creates shallow copies, why nested objects are shared, and when a deep copy is necessary.

MemberwiseCloneObject CloningShallow CopyICloneable
Diagram of shallow copy and deep copy of an object graph in C#.
C#

C# Shallow Copy vs Deep Copy

Understand the difference between shallow and deep copying in C#, how to implement each, and when to choose one over the other.

C#Object CopyingMemberwiseCloneDeep Copy
Diagram showing a value type being boxed into an object reference and later unboxed back to a value type.
C#

C# Object Casting and Boxing: How Type Conversion Works

Understand how C# object casting and boxing work, the runtime cost of boxing, common unboxing errors, and when to prefer generics over object conversions.

C#BoxingType CastingPerformance
Diagram showing a value type being boxed into a heap object with an arrow indicating the allocation overhead.
C#

C# Boxing Performance: Avoiding Hidden Allocations

c# boxing performance: Learn how boxing affects C# performance, where hidden allocations occur, and how generics help you avoid them in hot paths.

boxingunboxinggenericsmemory allocation
Illustration showing a boxed value (object) being opened to reveal the original value type inside, with C# and .NET purple color palette.
C#

Demystifying C# Unboxing

Practical C# unboxing guide: runtime mechanics, InvalidCastException pitfalls, nullable value behavior, and generic alternatives that reduce boxing.

.NETType CastingBoxingPerformance
Diagram showing a value type box being wrapped into a heap object with a reference pointer.
C#

C# Boxing Examples: How Value Types Behave

c# boxing examples: Understand C# boxing with practical examples: what happens on the heap, why unboxing requires exact type casts, and how to avoid boxing with generics.

boxingunboxingvalue typesgenerics
Illustration showing a value type boxed into a reference type object and unboxed back, with a warehouse metaphor for heap allocation.
C#

C# 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.

BoxingUnboxingPerformanceValue Types