Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我声明了一个具有许多类型参数的类:
public class A<T1, T2, T3, T4, T5> {}
我怎样才能使用这样的别名:
public class B<T1, T2, T3, T4, T5> { using T = A<T1, T2, T3, T4, T5> public void Method() { T.StaticMethod(); } }
您可以使用其余的 using 语句来执行此操作:
using MyList = System.Collections.Generic.Dictionary<int, string>;
然后你可以像这样使用这个类:
MyList x = new MyList(); x.Add(0, "Hello World");
然而,这有点糟糕的设计。在您发布的示例中, B 仍然有 5 个泛型类型参数,因此没有什么收获。