Re: public abstract static ...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"pali" <pali@xxxxxxxxxxxxxxxxxxxxxxxxx> a écrit dans le message de news:
62178611-DE77-47C2-9054-FBC14647487F@xxxxxxxxxxxxxxxx

| I was just wondering, why is not possible to make a member of a class BOTH
| abstract and static? MSDN says just that's in an error, not why this is
so.
| In a nutshell, I need this:
| I have an abstract base class called EntityBase that all my other business
| objects are derived from. I want to be able to load and save them in a
| generic manner. I use a static method called EntityBase.GetByID(int id)
and a
| member method called EntityBase.Save(). I want to be able to force every
| derived class to implement both of these methods, with this limitation I
| can't though. Is there any workaround? Is there any reason for this
| limitation in the first place?

Neither constructors or static members are allowed to be virtual in C#; you
can only declare virtual (and abstract) instance methods. That is just one
of the few limitations of the language.

Are you sure you want your method to be accessible without having to
instantiate the class it is included in ?

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


.



Relevant Pages

  • Re: Another stab at Cantor
    ... D1 is not a member of R. ... This is still nonsense. ... This time your *L_n lists each have a last but no first element, ... a limitation preventing some such strings from being produced. ...
    (sci.math)
  • Re: Group limitations
    ... the Domain Users group, and that group is set as their Primary Group. ... Windows 2000 considers a user to be a member of their primary group ... This limitation doesn't just affect group membership. ...
    (comp.os.ms-windows.nt.admin.security)
  • Re: From my best friend in Houston
    ... read the AAMT forums or over at MTDesk for more ... limitation on being a member to receive any of the benefit. ...
    (sci.med.transcription)
  • Re: Parent-Child 64000 limitation
    ... >I have a parent-child dimension which has hit the 64000 member ... > limitation. ... If I add an indexing level that is named the first letter of ... > the child member name to distribute the 64000 members, ...
    (microsoft.public.sqlserver.olap)
  • Re: "this" and "base"
    ... compiler and the programming language. ... a private inherited field in a base class from a derived class is that the ... > because the member "is a private". ...
    (microsoft.public.dotnet.languages.csharp)