top of page


On a recent interview I was asked what is a delegate, luckily I got the question right, the short answer is C# delegates are similar to pointers or functions found in C or C++ And a delegate is a reference type variable that holds the reference to a method.

But later I regretted that I didn't explain in more detail how to actually use it.

Delegate declaration determines the methods that can be referenced by the delegate.

Let's consider the following statement:

public delegate int MyDelegate (string s);

What I see here, the delegate MyDelegate can be used to reference any method that has a single string parameter and returns an int type variable.

bottom of page