"Jon Shemitz" <jo*@midnightbeach.comwrote in message
news:44***************@midnightbeach.com...
Shak wrote:
>I was led to believe that static methods were not inherited by their
subclasses (and since that makes sense, rightly so).
Huh? Why would you think that? The only thing special about static
methods is that they don't get a "this" reference. Public and internal
static members are just as visible to derived classes as they are to
totally unrelated classes; protected static members are just as
visible to derived classes as protected instance members.
Perhaps "inherited" was the wrong word. What I meant was that if a
superclass has a public static void method GetInt(), you would not be able
to call that method on a subclass - ie you can't mark them virtual.
My initial impression was that operators were just convienince for regular
static methods. So:
public static bool operator==(A one, A two), was equivalent to
public static bool myEquals(A one, A two).
They're not though, since, where B is a subclass of A:
B b1 = new B();
B b2 = new B();
bool result = (b1==b2); //compiles and uses the impl of operator== in A,
bool result2 = b1.Equals(b2); //doesn't compile, obviously.
I've since read after posting the OP that operators aren't just static
methods, and further what is to be called gets determined at compile time.
So, not only do you get access to any operators in the superclass, but you
may even get to use an operator that hasn't been explicity declared for your
type (like above with b1 == b2), which doesn't occur with regular virtual
methods (unless you cast).
Shak