您的位置:首页 > 编程语言 > C#

[泛型委托]-C# 三种泛型委托的使用

2014-11-14 23:48 323 查看
C# 三种泛型委托的使用Demo

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Demo
{
    class Program
    {

        static void Main(string[] args)
        {
            Action<string> test = delegate(string s) { Console.WriteLine(s); };
            test("Action delegate Test");

            Predicate<string> predicateTest = delegate(string s) { return s == "Hello"; };
            Console.WriteLine(predicateTest("Hello"));

            Func<string, string> func = delegate(string s) { return s + " Func"; };
            string result = func("Hello");
            Console.WriteLine(result);

            Console.ReadKey();
        }
    }
}
作为个人温习,请勿喷!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐