Browse by Topic

Popular

Latest

Latest C# Posts

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
C# code editor showing a using alias directive for a tuple type, with a highlighted tuple signature and a short alias name
C#

C# Using Alias for Tuple Types

c# using alias tuple: Learn how to use the C# using alias directive with tuple types to shorten repetitive type signatures and improve code readability.

C#tuplesusing aliastype aliases
Illustration of a C# using alias directive mapping a complex type signature to a simple name, with a code editor background.
C#

C# Alias Any Type with Using Directives

c# alias any type: Learn how to use C# 12's using alias directive to create aliases for any type, including tuples, arrays, and pointers, with practical examples and s...

C# 12using aliastype aliasesC# syntax
Illustration of a C# source file containing a type that is enclosed within a file boundary, representing file-local type scoping.
C#

C# File Local Type: Scoped Type Declarations

C# file-local types restrict type visibility to a single source file. Learn how they work, when to use them, and which constraints apply.

C# 11file-local typestype scopingC# accessibility