Creating a delegate is a mix between writing a function and declaring a variable:
public delegate returnType DelegateName(int param1, string param2);
You start with an access modifier followed by the delegate keyword, which identifies it to the compiler as a delegate type. A delegate type can have a return type and name as a regular function, as well as parameters if needed. However, this syntax only declares the delegate type itself; to use it, you need to create an instance as we do with classes:
public DelegateName someDelegate;
With a delegate type variable declared, it's easy to assign a method that matches the delegate signature:
public DelegateName someDelegate = MatchingMethod;
public void MatchingMethod(int param1, string param2)
{
// ... Executing code here ...
}
Notice that you don't include the parentheses when assigning MatchingMethod to the someDelegate variable, as it's not calling the method at this point. What it's...