nothrow
nothrow

Reputation: 16178

GenericTypeDefinition for type with multiple parameters

I have following code in C#

class c<T> { }
class d<T,E> { }
void Main()
{
    Console.WriteLine(typeof(c<>).FullName); // works
    Console.WriteLine(typeof(d<>).FullName); // CS0305 Using the generic type d<T, E> requires 2 type parameters
}

edit:

Console.WriteLine(typeof(d<int, int>).GetGenericTypeDefinition().FullName);

I expect:

c`1
d`2

does what I want, but I don't want to specify any types during compilation.

How to get GenericTypeDefinition for type d?

Upvotes: 0

Views: 88

Answers (1)

Dbl
Dbl

Reputation: 5914

Console.WriteLine(typeof(d<,>).FullName);

Upvotes: 3

Related Questions