Advertisement
Beginner C#, Delegates, Events & Lambdas

What is a delegate in C#, and what does it represent conceptually?

Short answer

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.

Save C# mock interview
Advertisement
AModel answer
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 delegate
Real-world example
Passing a specific comparison or transformation method as an argument to a generic sorting or processing function.
Likely follow-ups
  • How does a delegate differ from simply calling a method directly?
Related topics