• C# 委托的几种写法


    class Program
        {
            delegate string Get(string ss);
            delegate string Get2(int i);
            static Func<string, string> Out = s => s.ToLower();
            static Func<int, string> Out2 = s => { return s.ToString() + "这是Out2"; };
            static void Main(string[] args)
            {
                Get gt = Weituo.Lower;
                Get2 gt2 = Weituo.Upper;
                string test1 = "ABCDEFG";
                int test2 = 123456789;
                Console.WriteLine(gt(test1));
                Console.WriteLine(gt2(test2));
                Console.WriteLine(Out(test1));
                Console.WriteLine(Out2(test2));
                Console.ReadLine();
            }
        }
        public static class Weituo
        {
            public static string Lower(string str)
            {
                return "你输入的大写输出小写字母为:" + str.ToLower();
            }
            public static string Upper(int it)
            {
                return "你出入的数字输出为:" + it + "AAA";
            }
        }

  • 相关阅读:
    XML 的学习笔记3
    XML 的学习笔记2
    XML 的学习笔记1
    Tomcat 学习笔记2
    Tomcat 学习笔记1
    sol
    sol
    0、安装Ionic2
    ionic2 目录
    6、Angular Route 路由
  • 原文地址:https://www.cnblogs.com/wwj1992/p/4940091.html
Copyright © 2020-2023  润新知