On Tue, 22 May 2007 11:38:24 -0700, learning <ed**********@gmail.com>
wrote:
So but by doing that does it mean like I need to replciate all the
memebers,a nd just assign each of the replicated members to have value
same as the statiac class.. how can I sheild myself that if there is
any additona/deletion go teh satic member variables of the original
static class, i also need to keep in sync with that in my static
class.. is there a way that it can be automatic?
And I jsut need to worry about my own extension?
I've been following this thread a bit, and still haven't figured out
exactly what it is you are trying to do. That is, *why* you feel it would
be useful to inherit a new static class from an existing static class.
Inheritance is useful in situations where you have an instance, because
you can pass that instance around without always needing to know that it's
the more-derived version. It's nice that you can inherit behavior from a
base class, but the real power if you will comes from being able to have a
derived class passed to something that only knows the base class and still
have the inherited methods available, as well as being able to override
virtual methods (which allow the derived instance to change the behavior
of a method defined in the base instance, again without the caller
necessarily needing to know of the derived instance).
But those benefits rely on there being an actual instance of the class.
There's no instance of a static class, and so you can't pass an instance
of a derived static class to something that expects the base class. In
all cases of using a static class, the caller of the static class always
has to know which static class they are dealing with.
What does this mean in context of your question? Well, as Christof has
pointed out, there's no need to copy and paste code. Wherever you want to
use the functionality from the "base" static class, the caller will
specify that class, and wherever you want to use the functionality from
the "derived" static class, the caller will specify that class instead.
There is never any situation in which you are accessing a member of a
static class in which you don't specify the type name of that static
class, so there's really no point in wanting a method in some "base"
static class to magically show up some "derived" static class. If you
have new methods not contained in the "base" static class, just put them
in a new static class separate from the original static class, and then
call them directly from that class instead.
(And note that if you are concerned that your new static class won't have
access to hidden members of the "base" static class, members that you
would ordinarily have used "protected" access modifiers with, you can make
those members "internal" and your new static class will have access as
long as it's in the same assembly).
Pete