© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
Quick Links
Easy Studies

  HomeSource Code DotNet ► C# ▼

Multicast Delegate

It is possible to wrap more than one method in a delegate. If you make a call to a multicast delegate it will call all the functions it wraps in the order specified.

using System;
using System.Collections.Generic;
using System.Text;

namespace delegates
   public delegate void TestDelegate();
    class Test
        public static void Display1()
            Console.WriteLine("This is the first method");
        public static void Display2()
            Console.WriteLine("This is the second method");
        static void Main()
            TestDelegate t1 = new TestDelegate(Display1);
            TestDelegate t2 = new TestDelegate(Display2);
            t1 = t1 + t2; // Make t1 a multi-cast delegate
            t1(); //Invoke delegate

SLogix Student Projects