RE: Mybase.New() in VS 2005 by howlinghound
howlinghound
Fri Nov 11 10:42:03 CST 2005
Thanks Jeffrey!
Very convenient, though I wouldn't mind seeing the method to remind me. If a
base class has only parameterized constructors, and a call to the base
constructor is left out in a derived class, I guess that you wouldn't see the
error until compile time.
--
Michael Hockstein
""Jeffrey Tan[MSFT]"" wrote:
> Hi Michael,
>
> Thanks for your post.
>
> Below is the VB.net syntax in MSDN for MyBase.New() method:
> "In a derived class, every constructor must call a base class constructor
> (MyBase.New). If the base class has a constructor with no parameters that
> is accessible to derived classes, MyBase.New can be called automatically.
> If not, a base class constructor must be called with parameters, and this
> cannot be done automatically. In this case, the first statement of every
> derived class constructor must call a parameterized constructor on the base
> class, or call another constructor in the derived class that makes a base
> class constructor call."
>
> So, MyBase.New() is only needed if we want to call base class's
> parameterized constructor. If we just want to live with emptry parameter
> constructor, MyBase.New is no need, compiler will generate code to call it
> automatically.
>
> Hope this helps
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>
>