• Func<T, TResult>


    using System;

    delegate string ConvertMethod(string inString);

    public class Example
    {
    public static void Demo(System.Windows.Controls.TextBlock outputBlock)
    {
    // Instantiate delegate to reference UppercaseString method
    ConvertMethod convertMeth = UppercaseString;
    string name = "Dakota";
    // Use delegate instance to call UppercaseString method
    outputBlock.Text = convertMeth(name) "\n";
    }

    private static string UppercaseString(string inputString)
    {
    return inputString.ToUpper();
    }
    }




    using System;

    public class Example
    {
    public static void Demo(System.Windows.Controls.TextBlock outputBlock)
    {
    // Instantiate delegate to reference UppercaseString method
    Func<string, string> convertMethod = UppercaseString;
    string name = "Dakota";
    // Use delegate instance to call UppercaseString method
    outputBlock.Text = convertMethod(name) "\n";
    }

    private static string UppercaseString(string inputString)
    {
    return inputString.ToUpper();
    }
    }




    using System;

    public class Example
    {
    public static void Demo(System.Windows.Controls.TextBlock outputBlock)
    {
    Func<string, string> convert = delegate(string s)
    { return s.ToUpper(); };

    string name = "Dakota";
    outputBlock.Text = convert(name) "\n";
    }
    }


    using System;

    public class Example
    {
    public static void Demo(System.Windows.Controls.TextBlock outputBlock)
    {
    Func<string, string> convert = s => s.ToUpper();

    string name = "Dakota";
    outputBlock.Text = convert(name) "\n";
    }
    }
  • 相关阅读:
    分享一个详情页
    ES6初探,变量的声明
    ES6初探,什么是ES6
    提问回顾
    个人阅读&个人总结
    结对项目-数独程序扩展
    个人作业Week3-案例分析
    个人作业Week2-代码复审
    个人作业1
    【个人项目】数独
  • 原文地址:https://www.cnblogs.com/baobao2010/p/2246717.html
Copyright © 2020-2023  润新知