C# extension method as an interface implementation

Solution 1:

No, Extension methods can not act as implementation for an interface. Extensions methods are just syntactic sugar for a static method taking an instance of that class as the first parameter, thus not being a member of the specific class, which is a requirement for implementing an interface.

Solution 2:

this can not be done the way you describe it: C# method call resolution will always choose the concrete implementation of your method, never the extension method.

However, I believe you can -somewhat- get what you want if you DON'T define the method in the interface, but simply as extension methods in different namespaces. Of course, this is "static", in that the method called will still be selected at compile time.

Practically speaking, you then select the method called through the right "using" directive (similar to how LINQ works)

Solution 3:

This is not possible.

Interface methods must be implemented by the implementing type itself.

Extension methods are a purely language-level concept (syntax sugar), and won't help. The CLR itself is completely unaware of extension methods,

Solution 4:

var sim = new Sim()
((IEventHandler )sim).Notify(ev)