Re: Making static class ToString() not possible, why?



Zytan <zytanlithium@xxxxxxxxx> wrote:
"A static member 'function' cannot be marked as override, virtual or
abstract"

Is it possible to make a static class member function (which is also
static, obviously) that is an override to ToString()? Maybe it makes
no sense to do such a thing...

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.

--
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
.



Relevant Pages

  • Re: Making static class ToString() not possible, why?
    ... Is it possible to make a static class member function (which is also ... You could make a static ToString() method, but you can't override an instance method with a static method. ...
    (microsoft.public.dotnet.languages.csharp)
  • Making static class ToString() not possible, why?
    ... Is it possible to make a static class member function (which is also ... obviously) that is an override to ToString()? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# Inheritance
    ... The "override" keyword indicates that you are replacing the behaviour ... how to park itself via a Parkmethod, ... FordExpedition with its own Parkmethod, ... The technical term for this is "polymorphism". ...
    (microsoft.public.dotnet.csharp.general)
  • Re: static consts and inheritance
    ... member, and static members cannot be abstract, so I don't know how you ... "Override in derived classes" means polymorphism, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Polymorphism
    ... Polymorphism is a very broad subject, ... >>| pointer or reference is polymorphic. ... >>I assume you mean the virtual member function called 'walk', ... You need to override the virtual member in ...
    (alt.comp.lang.learn.c-cpp)

Loading