Re: Making static class ToString() not possible, why?
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Thu, 19 Apr 2007 21:38:03 +0100
Zytan <zytanlithium@xxxxxxxxx> wrote:
No, it doesn't. "Override" involves polymorphism, and polymorphism
doesn't apply to static members. To convince yourself of this, try to
work out what situation you'd expect it to be invoked in.
Yes, of course, those are OOP things, and a static class is basically
just a unit of functions. I don't want to inherit anything. I just
want a ToString() method that is automatically invoked when I append
it to a string. But, for that, I want the inherited method, don't I?
But what's the "it" here? You say you want it to be automatically
invoked when you append "it" to a string, but with a static class there
*isn't* anything to append. That's the problem.
This scenario came about from me converting a struct which overrode
ToString(), into a static class. Everything converted over fine,
except the ToString(), which is used only for debugging purposes, so
it's not a big issue. I am just curious about it.
Hope that's cleared things up for you.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- References:
- Making static class ToString() not possible, why?
- From: Zytan
- Re: Making static class ToString() not possible, why?
- From: Jon Skeet [C# MVP]
- Re: Making static class ToString() not possible, why?
- From: Zytan
- Making static class ToString() not possible, why?
- Prev by Date: Re: delegate in custom attribute
- Next by Date: Re: GC.Collect can be trusted?
- Previous by thread: Re: Making static class ToString() not possible, why?
- Next by thread: Re: Making static class ToString() not possible, why?
- Index(es):
Relevant Pages
|
Loading