.netvb.netoopoverloadingshadows

Shadows vs Overloads in VB.NET


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?


Solution

  • 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.