public delegate void OperationOnDelegate(int x,int y);
internal class Program
{
public static void Add(int x,int y)
{
Console.WriteLine($"Add:{x + y}");
}
public static void Sub(int x, int y)
{
Console.WriteLine($"Sub:{x - y}");
}
public static void Mul(int x, int y)
{
Console.WriteLine($"Sub:{x * y}");
}
static void Main(string[] args)
{
OperationOnDelegate op;
op = Add;
op(10, 20);
op = Sub;
op(10, 20);
op = Mul;
op(10, 20);
op = Add;
op += Sub;
op += Mul;
op(20, 10);
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter