Re: Inheritable Static methods



d-42 wrote:
Is there any way to make this method inheritable and have it behave
appropriately on inherited classes? Using generics? Extension methods?
Something else?

class baseClass
{
public static string ClassName()
{
return typeof(baseClass).FullName;
}
}

what I want is for:

class someClass : baseClass
{
...
}

and to be able to call someClass.ClassName() and have it return
"someClass"

obviously I can manually reimplement ClassName() in every inherited
subclass, but it strikes me that there should be -some- way of adding
a static method to a class that returns its own type name, without
having to do it manually for every inherited subclass.

Why is:

someClass.ClassName()

better than:

typeof(someClass).FullName

?

Arne
.


Loading