class ThirdType : SecondType
{
}
class SecondType : FirstType<SecondType>
{
}
class FirstType<T>
{
public static void ShowType()
{
Console.WriteLine(typeof(T).Name);
}
}
ThirdType.ShowType();
In this code, it will print "SecondType"
I want to know if it is possible to print "ThirdType" here?
I need a way when I call the static method ThirdType.ShowType(), it will print out ThirdType. Two ways I can think of is to modify the method to
public static void ShowType<O>()
{
Console.WriteLine(typeof(O).Name);
}
another way is
public static void ShowType(Type t)
{
Console.WriteLine(t.GetType().Name);
}
I can't think of any other ways
ThirdType.ShowType()instead ofFirstType<SecondType>.ShowType()to call it.