C# guides
Every published C# guide, newest first, with practical examples you can copy into your own project.
3,965 guides across 14 topics
Topics
Popular C# guides
Most readLatest C# guides
Page 22 of 77C# Span vs String: When to Use Each for Performance
Compare Span<T> and string in C# for memory efficiency and performance. Learn when to use each, how they differ, and see practical examples.
C# scoped ref: Controlling Reference Lifetimes
C# scoped ref: Learn how the scoped modifier in C# restricts reference lifetimes, prevents unsafe escapes, and improves safety with ref structs like Span<T>.
C# in vs ref vs out: Parameter Passing Explained
Learn how C# in, ref, and out parameter modifiers differ, when to use each, and how they affect method signatures and runtime behavior.
Understanding readonly ref in C#
Learn how readonly ref in C# lets you return and pass large structs by reference without mutation, reducing copies and improving performance.
C# ref readonly: Passing Large Structs Without Copies
Learn how C# ref readonly and in let you pass or return large structs by reference without copying while preventing the callee from modifying them. See syntax, performance trade-offs, and common pitfalls.
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# 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# 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# MemberwiseClone: Shallow Copy Basics
Learn how C# MemberwiseClone creates shallow copies, why nested objects are shared, and when a deep copy is necessary.
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.