Multicast delegates : Multi cast delegate « delegate « C# / CSharp Tutorial






using System;

class MainClass
{
  delegate int MyDelegate(string s);
  static void Main(string[] args)
  {
    string MyString = "Hello World";

    
    MyDelegate Multicast = null;

    Multicast += new MyDelegate(DoSomething);
    Multicast += new MyDelegate(DoSomething2);

    Multicast(MyString);
  }

  static int DoSomething(string s)
  {
    Console.WriteLine("DoSomething");
    
    return 0;
  }
  static int DoSomething2(string s)
  {
      Console.WriteLine("DoSomething2");
    return 0;
  }
}
DoSomething
DoSomething2








9.2.Multi cast delegate
9.2.1.Demonstrate multicasting
9.2.2.Multicast delegates
9.2.3.Remove delegate from Multicast
9.2.4.uses the reference parameter of a multicast delegate as a counter