Skip to content

Instantly share code, notes, and snippets.

@debugmodedotnet
Created April 18, 2019 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debugmodedotnet/c4c9e42560fcd23535f89655bf369bf2 to your computer and use it in GitHub Desktop.
Save debugmodedotnet/c4c9e42560fcd23535f89655bf369bf2 to your computer and use it in GitHub Desktop.
// 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