Alias for class with many typeparams in other class body (C#)
I declare a class with many typeparams:
public class A<T1, T2, T3, T4, T5> {}
How can I use alias like this:
public class B<T1, T2, T3, T4, T5>
{
开发者_JAVA技巧 using T = A<T1, T2, T3, T4, T5>
public void Method()
{
T.StaticMethod();
}
}
You can do this with the rest of your using statements:
using MyList = System.Collections.Generic.Dictionary<int, string>;
Then you can use the class like so:
MyList x = new MyList();
x.Add(0, "Hello World");
However, this is kinda bad design. In the example you posted, B still had 5 generic type arguments, so nothing much is gained.
精彩评论