Delegates and Func/Action in C#

From the C# Programming Language cheat sheet · Delegates and Events · verified Jul 2026

Delegates and Func/Action

Working with delegates and built-in delegate types

csharp
// Delegate declaration
public delegate void MyDelegate(string message);

// Using delegates
MyDelegate handler = Method1;
handler += Method2; // Multicast
handler("Hello");

// Built-in delegates
Action<string> logger = Console.WriteLine;
Func<int, int, int> add = (x, y) => x + y;
Predicate<int> isEven = n => n % 2 == 0;
💡 Delegates are type-safe function pointers
⚡ Action for void methods, Func for methods with return values
📌 Multicast delegates can call multiple methods
🟢 Events are special multicast delegates with restrictions
Back to the full C# Programming Language cheat sheet