zoukankan      html  css  js  c++  java
  • C# 委托实例实现的多种类型

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace ConsoleApplication17
    {
        public delegate string testDelegate(string a, int b);
        class Program
        {
            static void Main(string[] args)
            {
                //1 C# 1 最原始的委托赋值
                testDelegate t1 = new testDelegate(M);
    
                //2 C# 2 委托赋值
                testDelegate t2 = delegate (string a, int b)
                {
                    Console.WriteLine(a + b.ToString());
                    return a + b.ToString();
                };
    
                //3 C# 3 委托赋值(a,b值类型对应委托声明的类型)
                testDelegate t3 = (a, b) =>
                {
                    Console.WriteLine(a + b.ToString());
                    return a + b.ToString();
                };
                // 调用委托实例
                t1.Invoke("测试1", 665);
                t2.Invoke("测试2", 666);
                t3.Invoke("测试3", 667);
            }
            static string M(string a, int b)
            {
                Console.WriteLine(a + b.ToString());
                return a + b.ToString();
            }
        }
    }

  • 相关阅读:
    Win10系统下安装Tensorflow
    基于theano的深度卷积神经网络
    卷积层和池化层
    ReLu(Rectified Linear Units)激活函数
    向上取整&向下取整
    物品选取
    猫狗大战
    田忌赛马
    魔术棋子
    回文字串
  • 原文地址:https://www.cnblogs.com/lixipeng/p/10077285.html
Copyright © 2011-2022 走看看