Re: static method question
"Sean Woods" <swoods@eclickmd.com> wrote:
>Is there some way inside a static method to determine whether it is being
>called on a base class or an inherited class.
>
>So is this there a way to determine inside of MyMethod whether it was called
>via BaseClass.MyMethod or InheritedClass.MyMethod?
>
>If it wasn't static I could use "this" to get its type. So how do I do
it
>since it is static?
>
>Thanks
>Sean
If you use nonstatic methods, you can use this.GetType() to find out what
sort of class you're in.
... Or you can override a virtual method and have different behavior based
on the object type.
But you can't know what type of "class" you're in from a static non-virtual
method.
(Unless I'm wrong!)
-- Jeff
Re: static method question
As far as my knowledge goes, you cannot call a static method using the
object reference. You have to use the class name to do so. In these
scenario, does it really matter whether I am calling the function of the
base or the derived class? I know the type before making the call.
"Jeff Johnson" <jeff@nospam.com> wrote in message
news:3e4d1d22$1@tnews.web.devx.com...
>
> "Sean Woods" <swoods@eclickmd.com> wrote:
> >Is there some way inside a static method to determine whether it is being
> >called on a base class or an inherited class.
> >
> >So is this there a way to determine inside of MyMethod whether it was
called
> >via BaseClass.MyMethod or InheritedClass.MyMethod?
> >
> >If it wasn't static I could use "this" to get its type. So how do I do
> it
> >since it is static?
> >
> >Thanks
> >Sean
>
>
> If you use nonstatic methods, you can use this.GetType() to find out what
> sort of class you're in.
>
> .. Or you can override a virtual method and have different behavior based
> on the object type.
>
> But you can't know what type of "class" you're in from a static
non-virtual
> method.
>
> (Unless I'm wrong!)
>
> -- Jeff