• 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";
    }
    }
  • 相关阅读:
    百度高级搜索技巧
    JRebel插件使用详解
    css3自适应布局单位vw,vh详解
    vue的MVVM原理
    JS实现全屏和退出全屏
    设置不定宽高的元素垂直水平居中
    微信小程序启动更新机制
    了解MVVM原理
    xss攻击和csrf攻击的定义及区别
    跨站脚本漏洞(XSS)基础讲解
  • 原文地址:https://www.cnblogs.com/baobao2010/p/2246717.html
Copyright © 2020-2023  润新知