Re: public abstract static ...
- From: "Joanna Carter [TeamB]" <joanna@xxxxxxxxxxxx>
- Date: Thu, 23 Mar 2006 10:38:01 -0000
"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
.
- Prev by Date: Re: Multithread
- Next by Date: Re: URGENTCusom dialog boxes
- Previous by thread: How to get calling object type in static method of Base Class
- Next by thread: Re: public abstract static ...
- Index(es):
Relevant Pages
|