Whereas VB.NET's Shadows
keyword has an exact equivalent in C#, I've found elsewhere that the same is not true for its Overloads
keyword, at least in the context of inheritance. That being said, take the following code:
Public Interface IParent
Property SomeBool As Boolean
End Interface
Public Interface IChild
Inherits IParent
Overloads Property SomeBool As Boolean
End Interface
At first glance, when porting the interface IChild
, there doesn't seem to be a clear way to truly capture the exact meaning in C# without some sort of equivalent for Overloads
. If you try to do this:
public interface IChild : IParent
{
bool SomeBool { get; set; }
}
Then you're liable to get a warning to the following effect:
'IChild.IsDefaultValue' hides inherited member 'IParent.IsDefaultValue'. Use the new keyword if hiding was intended.
new
is the exact opposite of Overloads
. Without an equivalent keyword, how can you be sure that this is ported correctly?
While this question covers classes as well as interfaces, interfaces by definition block you from emulating this through implementation.
From the documentation:
Source: https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/modifiers/overloads
So, when used for shadowing,
new
would be the equivalent.