泛型类
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(); }