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

Comparison of C# delegate, Action, and Func with code snippets.
C#

C# Delegate vs Action vs Func: Which to Use?

Custom delegates, Action, and Func all let you pass methods around in C#. Learn how they differ and when each one is the clearest choice.

C# DelegatesActionFuncFunctional Programming
Illustration comparing C# Action and Func delegates, showing void versus return value
C#

C# Action vs Func: Choosing the Right Delegate

Understand the difference between Action and Func delegates in C#, including return types, type parameter order, async variants, and practical selection criteria.

C#DelegatesActionFunc
Diagram showing a predicate delegate filtering a list of items in C#
C#

C# Predicate Delegate: Usage and Examples

Learn how to use the C# Predicate<T> delegate to filter collections and express reusable conditions, with syntax, lambda examples, and common pitfalls.

PredicateDelegateLambdaLINQ
Diagram showing a C# Func delegate being passed as a parameter between two code blocks, representing method references and functional composition.
C#

C# Func Delegate: Syntax, Usage, and Practical Examples

Learn how to use the C# Func delegate to pass methods as parameters, write concise lambdas, and build flexible, reusable code.

delegateslambda expressionshigher-order functionsfunctional programming
A visual metaphor for the C# Action delegate showing a callable method box that returns void, with arrows representing input parameters.
C#

C# Action Delegate Usage with Examples

Learn how to use the C# Action delegate to pass methods as parameters, handle callbacks, and write flexible, reusable code with practical examples.

delegateslambda expressionsmethod groupshigher-order functions
Illustration of a C# delegate being invoked with a null-conditional operator, showing method chain and safety check.
C#

How to Invoke C# Delegates Safely

Practical guidance for invoking C# delegates safely: null handling, multicast behavior, exception isolation, return values, and async patterns.

delegatesinvocationnull-conditionalmulticast
Illustration of multiple method references chaining together in a delegate invocation list
C#

C# Multicast Delegate: Syntax and Behavior

Understand how C# multicast delegates chain method calls, how invocation lists behave at runtime, and practical patterns for safe event handlers.

delegateseventsinvocation listexception handling
C# code illustrating passing a method as a parameter using a delegate arrow symbol.
C#

C# Pass Method as Parameter: Delegates and More

Learn how to pass methods as parameters in C# using delegates, Func, Action, and lambdas, with practical examples and tradeoffs.

C# delegatesAction and Funchigher-order functionsevent handling
Illustration of a C# delegate declaration as a method signature, with a box representing a method reference and an arrow connecting to a target method.
C#

C# Delegate Declaration Explained

Learn how to declare and use C# delegates: signature matching, named methods, lambdas, multicast behavior, built-in Action and Func types, and events.

delegatesC#lambda expressionsmethod references
Illustration of a C# delegate linking a method to an event, with abstract method blocks and a connection arrow.
C#

Practical C# Delegate Usage

Understand C# delegates through practical examples: delegate syntax, multicast invocation, Func/Action types, closure capture, and when to use them for callbacks and events.

DelegatesC#Event HandlingLambda Expressions