Action<T> 委托
class Program
{
static void Main(string[] args)
{
MyDelegate<string>(MyFunc, "Hello World!");
MyDelegate<int>(MyFunc2, );
MyDelegate<string>(p => { Console.WriteLine("{0}", p); }, "Hello World");//使用Lambda表达式定义委托
Console.ReadKey();
} public static void MyDelegate<T>(Action<T> action, T p)
{
action(p);
}
private static void MyFunc(string s)
{
Console.WriteLine(s);
}
private static void MyFunc2(int s)
{
Console.WriteLine(s);
}
}