I'm trying to get the type parameter's name (ClassName<TypeParameterName>
) of geneic class from the class type.
for example something like this:
class MyClass<Type1>
{
public Type data;
}
static void Main()
{
Console.WriteLine(typeof(MyClass<int>).GetTypeParameterName());
//prints: Type1
}
I searched a lot and didn't find anything about how to do this.
the only thing I thought of was using StreamReader
and read the whole .cs file and find the type there in the text. But is there any faster/cleaner way to do this?
Note: I'm not trying to get the type of Type1 I'm trying to get the string "Type1".