Browse by Topic

Popular

Latest

Latest Posts

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

c# collection expression vs collection initializer: Compare C# collection expressions with collection initializers: syntax, type inference, span support, and when to u...

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
Technical diagram of a source generator placing an interceptor between a caller and the original method.
C#

Implementing C# Interceptors with a Minimal Example

C# interceptors let a method replace calls at specific source locations during compilation. This article shows a minimal source generator, how the compiler resolves intercepted calls, and when the preview feature is practical.

AOPsource generatorsruntime interceptionmethod interception
Code editor showing a C# lambda expression with an explicit return type highlighted.
C#

C# Lambda Explicit Return Type

c# lambda explicit return type: Learn when and how to specify an explicit return type for a C# lambda expression, including syntax, limitations, and practical examples.

lambda expressionsC# syntaxtype inferenceFunc delegates
Diagram showing a lambda expression blocked from using a ref parameter, with a local function alternative shown as a path
C#

C# Lambda Ref Parameter: Why It's Not Allowed

c# lambda ref parameter: Learn why C# lambda expressions cannot declare ref parameters and how to use local functions or wrapper types to achieve pass-by-reference beh...

C#Lambda ExpressionsRef ParametersLocal Functions
Diagram showing lambda expression parameter syntax in C#
C#

C# Lambda Params: Syntax and Common Pitfalls

Learn how to define lambda parameters in C#, including implicit and explicit types, multiple parameters, and working with params arrays through delegates.

C# LambdaDelegatesFunctional ProgrammingParameters
C# code showing a using alias for a generic type being declared and used
C#

C# Using Alias for Generic Types

Learn how C# using aliases shorten closed generic type names, why open generic types cannot be aliased, and when a wrapper class may be a better fit.

C#type aliasesgeneric typescode readability