标签:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 泛型对类型参数的推断 { class Program { public static void genericMtthod<T>( T t1, T t2) { T temp = t1; t1 = t2; t2 = temp; } static void Main(string[] args) { int a = 1, b = 2; genericMtthod( a, b); Console.WriteLine("a:" + a); Console.WriteLine("b:" + b); string c="c",d="d"; genericMtthod( c, d); Console.WriteLine("c:" + c); Console.WriteLine("d:" + d); Console.ReadKey(); } } }
运行效果图:
标签:
原文地址:http://www.cnblogs.com/xiefengdaxia123/p/5983035.html