C# 泛型类


泛型类

public
class TestClass<T, A> { public T t; public A a; public TestClass(T t) { this.t = t; } public TestClass(A a) { this.a = a; } public T GetT() { return t; } }

调用
static void Main(string[] args) { TestClass<string, int> testClass = new TestClass<string, int>("Hello World"); Console.WriteLine(testClass.t); Console.ReadKey(); }

  

原文地址:https://www.cnblogs.com/xiaobao2017/p/10312726.html