using System;
namespace Sumit_Delegate_Sample
{
class Program
{
// STEP 1: Declare a Delegate
public delegate void DoAll(int a, int b);
static void Main(string[] args)
{
// Create instance of delegate
DoAll doit = add;
doit += substraction;
doit += multiplication;
// Use Delegate like a method
Console.WriteLine(" Output is below : ");
doit(6,5);
Console.ReadKey();
}
// STEP 2: Define handeler Method (Declare a method with the same signature as the delegate.)
public static void add(int x, int y)
{
Console.WriteLine("\n Addition is : " + (x + y));
}
public static void substraction(int x, int y)
{
Console.WriteLine("\n substraction is : " + (x - y));
}
public static void multiplication(int x, int y)
{
Console.WriteLine("\n multiplication is : " + (x * y));
}
}
}This code snippet for MultiCast Delegate Sample.
