C# › Delegates, Events & Lambdas
What is a delegate in C#, and what does it represent conceptually?
BeginnerAnswer
A delegate is a type-safe reference to a method with a specific signature — it lets you treat methods as values you can store in variables, pass as parameters, and invoke indirectly, similar to a function pointer but fully type-checked by the compiler.
public delegate int MathOperation(int a, int b);
int Add(int a, int b) => a + b;
MathOperation op = Add;
int result = op(3, 4); // 7, invoked through the delegateReal-world example Passing a specific comparison or transformation method as an argument to a generic sorting or processing function.