The code that prints the type is a base class method. With the exception of the rare Reflection scripts that you indicated above, the execution will not depend on whether the method is called using the derived type or the base type, so the system does not make any differences.
However, you can get around this by specifying a common base type:
class ClassNameTesterBase <T> where T: ClassNameTester <T>
{
public static String getName () {return (typeof (T)). Name; }
}
and then defining other types of interests:
class ClassNameTester1 <T & gt: ClassNameTesterBase <T> ...
class ClassNameTester2 <T & gt: ClassNameTester1 <T> ...
Then you can optionally define sheet classes:
class ClassNameTester1: ClassNameTester1 <ClassNameTester1> {}
class ClassNameTester2: ClassNameTester2 <ClassNameTester2> {}
One small caveat here is that ClassNameTester2 derives its internals from ClassNameTester1 <T> but cannot be replaced with anything related to ClassNameTester1 <ClassNameTester1> ;; if it is used as a static class, this should not be a problem.
source share