zoukankan      html  css  js  c++  java
  • Lambda

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Lambda //匿名方法,用来实现委托
    {
        class Program
        {
    
            delegate string nRnC(int x, float y);
    
            static void Main(string[] args)
            {
                // delegat
                nRnC mod_1 = new nRnC(func);
                nRnC mod_2 = func;
    
                //to lambda 演化过程
                nRnC moc_3 = new nRnC(delegate (int x, float y) { return ""; });
    
                nRnC mod_4 = new nRnC((int x, float y) => { return ""; });
    
                nRnC mod_5 = new nRnC((x, y) => { return ""; });
    
                nRnC mod_6 = (x, y) => "";
    
    
                //由框架提供的委托类型
                //无返的
                Action act0 = () => Console.WriteLine("无参无返");
                Action<int> act1 = x => Console.WriteLine("1 参无返");
                Action<int, int> act2 = (x, y) => Console.WriteLine("2 参无返");
                //有返的,最后一个参数就是返回值
                Func<string> func0 = () => "无参有返";
                Func<int, string> func1 = x => "1 参有返";
                Func<int, double, string> func2 = (x, y) => "多参有返";
    
            }
            private static string func(int x, float y)
            {
                return "";
            }
        }
    }
    

      

  • 相关阅读:
    目标检测:YOLOV2
    目标检测:YOLOV1
    格拉姆矩阵(Gram matrix)详细解读
    Java 线程Thread.Sleep详解
    luogu2429 制杖题
    luogu2441 角色属性树
    luogu2398 SUM GCD
    luogu2303 [SDOI2012] Longge的问题
    luogu2054 洗牌 同余方程
    线性同余方程
  • 原文地址:https://www.cnblogs.com/Jeely/p/11003390.html
Copyright © 2011-2022 走看看