using System;using System.Collections.Generic;public delegate void DExchange<T>(ref T t1,ref T t2);public interface IExchange<T> ...
using System;using System.Collections.Generic;public delegate void DExchange<T>(ref T t1,ref T t2);public interface IExchange<T>{ void Swap(ref T t1,ref T t2);}public class MyClass<T,V>: IExchange<T>{ public void Swap(ref T t1,ref T t2) { T temp = t1; t1 = t2; t2 = temp; } public void SayHello<M>(V v1,M m1) { return; }}public class RunMyApp{ public static void Main() { get='_blank'>string xu = "Xu Minghui"; string liu = "Liu Jie"; MyClass<string,int> my = new MyClass<string,int>(); my.Swap(ref xu,ref liu); IExchange<string> IE = my; IE.Swap(ref xu, ref liu); DExchange<string> de = my.Swap; de(ref xu, ref liu); Console.WriteLine(xu); Console.ReadKey(); }}
原标题:泛型方法、泛型接口、泛型代理、泛型类别测试
关键词:接口
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。