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() { 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(); }}
详细解决方案
泛型方法、泛型接口、泛型署理、泛型类别测试
热度:305 发布时间:2016-04-28 08:19:02.0
相关解决方案