Re: overides/loads usage
- From: "RdS" <rds@xxxxxxxxxxxxx>
- Date: Sun, 16 Jul 2006 18:01:33 -0400
Thank you very much for responding.
#1 ok. I understand now. Is the new constructor the only procedure that
executes the new() in base before the derived?
#2 But why not always use overloading or shadowing rather than overriding?
It seems that you can accomplish what you need with overloading and
shadowing especially since to override (as you said) requires the
overridable keyword in base class. When do I use overloading verses
shadowing?
Thanks again.
"Scott M." <s-mar@xxxxxxxxxxxxx> wrote in message
news:uuxZK6QqGHA.4408@xxxxxxxxxxxxxxxxxxxxxxx
i see that the base class has a new procedure with no arguments. The
arguments in both base and derived classes are the same. Is the new
procedure in the derived class shadowing or overriding the new procedure
in base class? I understand that it would be easy to tell if the coder
specified keyword of overrides or shadows, but they didn't.
The answer is neither. Constructors are "special", in that, they neither
shadow or override other constructors from their base classes. Take this
example:
Public Class A
Sub New()
End Sub
End Class
Public Class B
Inherits A
Sub New()
End Sub
End Class
If you were to make an instance of "B", the constructor from class "A"
will fire and then the constructor from class "B".
#2 In another derived class I see two new procedures. One with no
parameters like one in base class and the other with two parameters. I
understand that the constructor is overloaded, but is the new with no
parameters shadowing or overriding the new in base class.
Nether again. The constructor in the derived class that takes the
parameters is overloading the constructor in the derived class AND the
constructor in the base class.
How can one know if shadowing is being used or if overriding is being
used when no keyword is specified in procedure declaration?
Simple. To use Shadowing or Overloading in VB.NET, the Shadows and
Overrideable and Overrides keywords MUST be specified. If you don't see
those words, they are not being used.
Thanks in advance.
.
- Follow-Ups:
- Re: overides/loads usage
- From: Scott M.
- Re: overides/loads usage
- References:
- overides/loads usage
- From: RdS
- Re: overides/loads usage
- From: Scott M.
- overides/loads usage
- Prev by Date: ListView and ImageList/ImageKey
- Next by Date: arrow key press forces inheritors of control to throw away focus??!!
- Previous by thread: Re: overides/loads usage
- Next by thread: Re: overides/loads usage
- Index(es):
Relevant Pages
|