Cheers,
I've been messing around with some AspNet identity stuff trying to decouple some components.
When I try to define an interface that implements other interfaces (in this case AspNet Identity interfaces) I get a warning in visual studio that tells me that I must use the reserved word "new" in each member of the interface because it is hiding a member of the interfaces that my interface implements.
Although the warning is effectively removed by adding to the beginning of the definition of each member in the interface, I would like to know the reason for this warning and the implications that using "new" at the beginning of each member in the definition of the interface may have. Interface.
Thank you very much.
Correct me if I'm not correct.
When you implement one interface in another, the word
new
is not that important unless you need to change something in that part.Basically you are saying "I want my new interface to be like the other one, but I want to change some things"
Example:
The definition of
IAnotherElement.Nombre
is going to hide the direct behavior ofIElement.Nombre
so you are only going to modify what happens. In the example above, both definitions are valid, however, the warning is just a warning telling you that it may corrupt the behavior of the parent interface.Using the example above, if you hide a property, that element cannot be inherited by classes that implement that property:
Note the
new
in the class implementation.But if we remove the
new
:The compiler warns you that the operator is missing
set
from the property definition.I hope it has helped you, here is a fiddle for you to see!!