This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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