Pages

Topics

Tools

↑↓navigate↵openescclose

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

Latest C# guides

A visual comparison of C# field and property showing encapsulation layers
C#

C# Property vs Field: When to Use Each

Learn the differences between C# properties and fields, including encapsulation, validation, computed values, performance, and when to choose each.

C#propertiesfieldsencapsulation
Diagram comparing C# delegate and event invocation paths, showing how events restrict external callers.
C#

C# Delegate vs Event: The Practical Difference

Learn the practical differences between delegates and events in C#, including invocation rules, access control, and when each design fits your code.

delegateseventsC# programmingevent handling
Illustration comparing C# List and Dictionary collections with keys and indices.
C#

C# List vs Dictionary: Choosing the Right Collection

c# list vs dictionary: Compare C# List and Dictionary for lookups, iteration, and memory. Learn when each collection fits best with code examples.

C# CollectionsListDictionaryPerformance
Illustration showing three C# parameter modifier keywords ref, out, and in with arrows indicating data flow direction between caller and method.
C#

C# ref vs out vs in: Parameter Modifiers Explained

c# ref vs out vs in: Understand how ref, out, and in parameter modifiers differ in C#, when each is is required,, and how they affect runtime behavior and API design.

C#parameter modifiersref out inmethod parameters
Comparison of C# const, readonly, and static readonly modifiers with a code snippet and a scale showing compile-time versus runtime initialization.
C#

C# const vs readonly vs static readonly: What to Use When

C# const vs readonly vs static readonly: Learn the differences between these modifiers, including initialization timing, memory behavior, and when each is the right choice.

C#constreadonlystatic readonly
Diagram comparing class, struct, and record in C# showing value and reference semantics.
C#

C# Class vs Struct vs Record: Choosing the Right Type

Choose the right C# type by learning how class, struct, and record differ in reference vs value semantics, equality, performance, and common use cases.

C#StructsRecordsValue Semantics
A visual comparison of the C# switch statement and switch expression showing syntax differences and pattern matching.
C#

C# Switch Statement vs Switch Expression: Which to Use?

Compare the classic C# switch statement with the switch expression: syntax, pattern matching, exhaustiveness, and when each form fits best.

C# switch expressionC# switch statementpattern matchingC# 8
Illustration comparing C# collection expression syntax with collection initializer syntax showing two code paths converging on a single collection.
C#

C# Collection Expression vs Collection Initializer

Compare C# collection expressions and collection initializers: syntax, type inference, span support, and when to use each.

C#Collection ExpressionsCollection InitializersC# 12
Illustration comparing C# collection initializer and object initializer syntax, showing a list with elements being added and an object with property assignments.
C#

C# Collection Initializer vs Object Initializer

c# collection initializer vs object initializer: Understand the difference between C# collection initializers and object initializers, how the compiler translates each...

C#Collection InitializerObject Initializer.NET
C# code with an interceptor attribute redirecting a method call at compile time.
C#

C# InterceptsLocation Attribute Usage

Learn how to use C# InterceptsLocationAttribute with source generators to redirect method calls at compile time, including syntax, limitations, and debugging tips.

C# source generatorsinterceptorcompile-time code generationROS