Make interface methods with a default implementation visible on derived types #8244
Unanswered
jamesfoster
asked this question in
Language Ideas
Replies: 2 comments 3 replies
-
What would happen if a class implements two interfaces with conflicting members? |
Beta Was this translation helpful? Give feedback.
2 replies
-
The details are probably buried in the issues, but the design decision was that default implementations work like explicit implementation and that the members do not appear on the implementing type: Interface members aren't inherited, and implementing an interface does not require that the implementing type expose public members of the matching name/signature. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
sharplab.io example
dotnet/roslyn#74138
I had a look for previous discussion on the topic but didn't find anything. Is this something you'd concider supporting?
To me this feels more natural. Methods and properties declared on an interface must be implemented by non-abstract derived types. However, if the interface gives a "default" implementation, the derived type has the option of implementing it or omitting it and therefore accepting the default implementation.
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/default-interface-methods
Beta Was this translation helpful? Give feedback.
All reactions