zoukankan      html  css  js  c++  java
  • Lambda expressions and expression trees

    1. introducing the Func<…> delegate types

      Here are the signatures
    of all the Func delegate types:
    public delegate TResult Func<TResult>()
    public delegate TResult Func<T,TResult>(T arg)
    public delegate TResult Func<T1,T2,TResult>(T1 arg1, T2 arg2)
    public delegate TResult Func<T1,T2,T3,TResult>
    (T1 arg1, T2 arg2, T3 arg3)
    public delegate TResult Func<T1,T2,T3,T4,TResult>
    (T1 arg1, T2 arg2, T3 arg3, T4 arg4)

    Func<string,double,int> is equivalent to a delegate type of the form
    delegate int SomeDelegate(string arg1, double arg2)

     

    Func<string> returnHello;
                Func
    <stringstring> returnContent;
                Func
    <stringint> returnLength;

                returnHello 
    = () => { return "Hi David!"; };
                returnContent 
    = (string text) => { return text; };
                returnLength 
    = (string text) => { return text.Length; };

                Console.WriteLine(returnHello());
                Console.WriteLine(returnContent(
    "Hi David!"));
                Console.WriteLine(
    "Length of content: " + returnLength("Hi David!"));

     

    技术改变世界
  • 相关阅读:
    spring boot所有配置
    Hibernate validator的一些额外特性
    相似序列搜索
    时间序列异常检测
    基于结构的距离度量
    jupyterlab的启动404error问题
    爬虫-Chrome-问题1
    厘清重要概念的内涵与外延
    六)定时任务持久化
    公钥私钥
  • 原文地址:https://www.cnblogs.com/davidgu/p/2174132.html
Copyright © 2011-2022 走看看