Home All Groups Group Topic Archive Search About

Can not create 2 properties with same signature.

Author
11 Jul 2006 4:27 PM
Mythran
Why can't we create 2 properties with the same signature .. one on a base
class and one on a derived class, even though both properties are shared?

Public Shared ReadOnly Property MyProperty() As Integer

Thanks,
Mythran

Author
11 Jul 2006 4:44 PM
Jared Parsons [MSFT]
Hello Mythran,

> Why can't we create 2 properties with the same signature .. one on a
> base class and one on a derived class, even though both properties are
> shared?
>
> Public Shared ReadOnly Property MyProperty() As Integer

It is legal to do this.  Add the Shadows keyword to the definition to explicitly
state you want this behavior.

Public Shared Shadows ReadOnly Property MyProperty() As Integer


--
Jared Parsons [MSFT]
jared***@online.microsoft.com
All opinions are my own. All content is provided "AS IS" with no warranties,
and confers no rights.
Author
11 Jul 2006 7:20 PM
Herfried K. Wagner [MVP]
"Mythran" <kip_potter@hotmail.comREMOVETRAIL> schrieb:
> Why can't we create 2 properties with the same signature .. one on a base
> class and one on a derived class, even though both properties are shared?
>
> Public Shared ReadOnly Property MyProperty() As Integer


Shared members are not overridable (virtual in C{#, ++} terms), thus this is
not possible.  In other words it's not possible (except by using 'Shadows',
but I think this is not a good solution) to change the behavior of a shared
member in a derived class.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>