When we have new in C#, that personally I see only as a workaround to override a property that does not have a virtual/overridable declaration, in VB.NET we have two "concepts" Shadows and Overloads.
In which case prefer one to another?
When we have new in C#, that personally I see only as a workaround to override a property that does not have a virtual/overridable declaration, in VB.NET we have two "concepts" Shadows and Overloads.
In which case prefer one to another?
Shadows is for cases where your base class is Function SomeMethod() As String and you want to have Function SomeMethod() As Integer. Basically, to change the return type.
Overloads is for case where your base class is Function SomeMethod() As String and you want to add a parameter such as Function SomeMethod(ByVal value As Integer) As String.
There are three closely related concepts; overriding, shadowing and overloading.
Overriding is when you make a new implementation for a virtual method.
Shadowing is when you make a new non-virtual implementation for a method.
Overloading is when you add a method with the same name but different parameters.
All three concepts are available both in C# and VB.