I’ve noticed that a class can “overload” a read-only property of its parent class, even though this isn’t allowed within a class. I don’t understand why this is allowed or what (if anything) it accomplishes.
Class myClass
ReadOnly Property SomeProp As Integer
Get
Return 50
End Get
End Property
End Class
Class mySubClass
Inherits myClass
Overloads ReadOnly Property SomeProp As Integer
Get
Return 12
End Get
End Property
End Class
The signature of mySubClass.SomeProp is identical to myClass.Prop—how can the former overload the latter?
In practice this seems to function just like Shadows, is that true?
In essence yes, with the overload you’ll have myClass::SomeProp and mySubClass::SomeProp
Given an instance of mySubClass, calls to SomeProp will resolve to mySubClass::SomeProp as the best match. However since it’s Overloads and not Shadows, something like
won’t compile since it lacks the Overloads decorator.