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

  

posted @ 2019-01-24 09:36  小包2017  阅读(85)  评论(0编辑  收藏  举报