zoukankan      html  css  js  c++  java
  • 系统内置的泛型委托

    #region 系统内置的泛型委托
    //只要是Action委托都是无返回值的。

    ////1.存储无参数无返回值的方法
    //Action md = () => { Console.WriteLine("无参数无返回值。"); };
    //md();
    //Console.Read();


    ////2.有一个参数没有返回值
    //Action<string, int> md = (s, i) => { Console.WriteLine(s + " " + i); };
    //md("aaaaaaa", 10);
    //Console.Read();

    //当需要存储带返回值的方法的时候,就需要使用另外一个泛型委托Func


    //Func<string> fn = T1;

    //string ss = fn();
    //Console.WriteLine(ss);
    //Console.Read();


    ////返回值是string类型,参数是一个int类型
    //Func<int, string> fn = n => n.ToString();
    //Console.WriteLine(fn(10));
    //Console.Read();

    //Func<int, int, string> fn = T2;
    //Console.WriteLine(fn(12, 5));
    //Console.Read();

    //Action<string>
    #endregion

  • 相关阅读:
    socket:套接字
    hashlib 加密
    面向对象总结
    类的内置方法
    反射
    类中的三个装饰器方法
    text
    模块
    练习1
    内置函数
  • 原文地址:https://www.cnblogs.com/poli/p/4069312.html
Copyright © 2011-2022 走看看