c# 多播委托

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

namespace _10多播委托
{
    public delegate void Del1();
    class Program
    {
        static void Main(string[] args)
        {
            Del1 del1 = T1;
            //多播委托:就是让一个委托能够指向多个函数
            del1 += T2;
            del1 += T3;
            del1 += T4;
            del1 -= T3;
            del1 += T3;

            del1();
            Console.ReadKey();
        }

        static void T1()
        {
            Console.WriteLine("我是T1");
        }
        static void T2()
        {
            Console.WriteLine("我是T2");
        }
        static void T3()
        {
            Console.WriteLine("我是T3");
        }
        static void T4()
        {
            Console.WriteLine("我是T4");
        }

    }
}

 

posted on 2017-06-13 15:49  算顺网  阅读(140)  评论(0编辑  收藏  举报

导航