using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace TestCS
{
class Program
{
//定义一个含有一个参数,不返回值的代理
delegate void GenericDelegate<T>(T param);
public static void Main(string[] args)
{
GenericDelegate<string> gs = new GenericDelegate<string>(StringMethod);
gs("String methode");
GenericDelegate<int> gs2 = new GenericDelegate<int>(IntMehtod);
gs2(2);
}
public static void StringMethod(string arg)
{
Console.WriteLine("I'm a string-->" + arg);
}
public static void IntMehtod(int arg)
{
Console.WriteLine("I'm an Int -->" + arg);
}
}
}
泛型的代理--Generic delegate
最新推荐文章于 2024-05-12 17:15:22 发布