How to force implementation of concrete interface methods
How do I force the default the requirement for implementation of interface methods which have a body / default implementation? (C# 8)
3 Replies
You don't
Default implementations mean that if something implements the interface, it doesn't have to implement the default members
The solution would be to just not provide default implementation
Because why would you, if you require the classes to implement those members anyway?
yeah I've just been reading and it seems the motive for default implementation is different from my use case. I'm not sure what I need in this case. My goal is to make my code as exstensible as possible.
Many different objects will all require very similar but slightly different implementation of the the same methods. I was hoping the default implementation would allow me to define these methods as a base to then modify within the derived classes but I now understand this is not the reason for default implementation. Any ideas what I might be looking for? If I have to just copy and paste code then I can.
probably an abstract class with virtual methods that can be overridden if necessary