zoukankan      html  css  js  c++  java
  • 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";
    }
    }
  • 相关阅读:
    洛谷 P1919 【模板】A*B Problem升级版(FFT快速傅里叶)
    Codeforces Goodbye 2018
    ubuntu 百度云
    【UOJ 351】新年的叶子
    【SDOI2008】仪仗队
    NOI 2002 贪吃的九头龙
    最大获利
    codeforces 814E An unavoidable detour for home
    codeforces 814D An overnight dance in discotheque
    bzoj3191 [JLOI2013]卡牌游戏
  • 原文地址:https://www.cnblogs.com/baobao2010/p/2246717.html
Copyright © 2011-2022 走看看