void Main()
{
// 泛型委托 ACTION FUNC
// 3. 创建委托实例
TestDele<string> testDele = new TestDele<string>(HellowDele);
testDele("测试委托");
// 官方版本的泛型委托(不带返回值)
Action<string> action = new Action<string>(HellowDele);
action("官方版本泛型委托");
// 带返回值的泛型委托 ps: <> 中的最后一个类型就是返回值类型
Func<string,int> func = new Func<string,int>(HellowFunc);
int i = func("有返回值的泛型委托FUNC");
Console.WriteLine(i); // 接收泛型返回值 ++++++++++++++++++++++++++++++++-
}
// 1. 定义一个泛型委托(不带返回值)
delegate void TestDele<T>(T t);
// 2. 定义一个方法
public void HellowDele(string str){
Console.WriteLine(str);
}
public int HellowFunc(string str){
Console.WriteLine(str);
return 123;
}
class parentC{
class Child{
}
}