委托 多播

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 多播委托
{
    public delegate void  Dele();
    class Program
    {
        static void Main(string[] args)
        {
            Dele del = showMsg1;
            del += showMsg2;
            del += showMsg3;
            del += showMsg4;

            del -= showMsg1;
            del -= showMsg3;

            del();

            Console.ReadKey();
        }

        public static void showMsg1()
        {
            Console.WriteLine("T1");
        }

        public static void showMsg2()
        {
            Console.WriteLine("T2");
        }

        public static  void showMsg3()
        {
            Console.WriteLine("T3");
        }

        public static void showMsg4()
        {
            Console.WriteLine("T4");
        }
    }
}

显示

 

posted @ 2017-11-14 12:05  mCat  Views(143)  Comments(0Edit  收藏  举报