Re: Inheritable Static methods
- From: Arne Vajhøj <arne@xxxxxxxxxx>
- Date: Mon, 26 May 2008 18:25:48 -0400
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
.
- Follow-Ups:
- Re: Inheritable Static methods
- From: d-42
- Re: Inheritable Static methods
- References:
- Inheritable Static methods
- From: d-42
- Inheritable Static methods
- Prev by Date: Inheritable Static methods
- Next by Date: Re: Inheritable Static methods
- Previous by thread: Inheritable Static methods
- Next by thread: Re: Inheritable Static methods
- Index(es):
Loading