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();
}
}
}
作为个人温习,请勿喷!