delegate的参数也可泛型【简单源码示例】
using System;
using System.Reflection;
using System.Collections.Generic;
using System.Text;
namespace TestSpace
{
delegate bool Predicate<T>(T value);
class x
{
static bool F(int i) { return true; }
static bool G(string s) { return false; }
static void Main()
{
Predicate<string> p2 = G;//false
Predicate<int> p1 = new Predicate<int>(F);//true
bool a = p1(1);
bool b = p2("2");
Console.WriteLine(b);
Console.WriteLine(a);
Console.ReadLine();
}
}
}
posted on 2010-05-11 18:38 Master zhu 阅读(168) 评论(0) 编辑 收藏 举报