Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// declaring a delegate
public delegate int AddDelegate(int num1, int num2); // 1
static void Main(string[] args)
{
AddDelegate d1 = new AddDelegate(add); // 2
int result = d1(7, 2); // 3
Console.WriteLine(result);
Console.ReadKey(true);
}
public static int add(int a, int b) // function
{
Console.WriteLine(" A Delegate Called me");
int res;
res = a + b;
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment