What is a delegate in C#?

Answer

A delegate is a type-safe function pointer — it holds a reference to a method with a specific signature. Delegates enable: passing methods as parameters, callbacks, and events. Declaration: public delegate int MathOperation(int a, int b);. Usage: MathOperation add = (a, b) => a + b; int result = add(3, 4);. Built-in delegates: Action (void return, 0-16 parameters), Func (non-void return, last type param is return type), Predicate<T> (bool return). Delegates are multicast — they can hold multiple method references: delegate += AnotherMethod; — all methods are called when the delegate is invoked. Delegates underpin events, LINQ (lambda expressions), and async callbacks. Modern C# prefers lambdas and built-in generic delegates over custom delegate declarations.