Skip to content

Instantly share code, notes, and snippets.

@luisdeol
Created January 7, 2018 22:32
Show Gist options
  • Save luisdeol/9f481816a0a51babb6515594a04dda6d to your computer and use it in GitHub Desktop.
Save luisdeol/9f481816a0a51babb6515594a04dda6d to your computer and use it in GitHub Desktop.
Understanding Delegates
using System;
namespace create_implement_events_callbacks
{
class Program
{
public delegate int Calculate(int x, int y);
public static int Add(int x, int y)
{
return x + y;
}
public static int Multiply(int x, int y)
{
return x * y;
}
static void Main(string[] args)
{
Calculate calc = Add;
Console.WriteLine(calc(3, 4));
calc = Multiply;
Console.WriteLine(calc(3, 4));
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment