Exemple #1
0
        public delegate void /*委托返回类型*/ GetTelphone(string message); /*委托方法名称*/   //用来得到联系方式的

        internal static void Demonstration()
        {
            var         del      = (GetTelphone)((message) => { Console.WriteLine($"delegate {message}得到屌丝的电话"); });
            var         del2     = (GetTelphone)((message) => { Console.WriteLine($"Func {message}得到屌丝的电话"); });
            var         del3     = (GetTelphone)((message) => { Console.WriteLine($"Action {message}得到屌丝的电话"); });
            var         del4     = (GetTelphone)((message) => { Console.WriteLine($"Predicate {message}得到屌丝的电话"); });
            var         del5     = (GetTelphone)((message) => { Console.WriteLine($"EventHandler {message}得到屌丝的电话"); });
            GetTelphone instance = null;

            instance += del;
            instance += del2;
            instance += del3;
            instance += del4;
            instance += del5;

            instance.Invoke("媒婆");
        }
Exemple #2
0
 public static void GetTel(GetTelphone getTelphone)
 {
     Console.WriteLine(getTelphone.Invoke("媒婆"));
 }