Advertisement
Beginner C#, Delegates, Events & Lambdas

What is a delegate in C#?

Short answer

A delegate is a type-safe reference to a method, letting you pass behaviour as a parameter and invoke it later. Func<>, Action<> and Predicate<> are built-in delegates.

Save C# mock interview
Advertisement
AModel answer
A delegate is a type-safe reference to a method, letting you pass behaviour as a parameter and invoke it later. Func<>, Action<> and Predicate<> are built-in delegates.
Func<int,int> square = x => x*x;
Action<string> log = Console.WriteLine;
Console.WriteLine(square(4)); // 16
Real-world example
Passing a comparison or projection function into a sorting or LINQ method.