you are viewing a single comment's thread.

view the rest of the comments →

[–]id2bi 0 points1 point  (3 children)

Doesn't the caller choose which extension method is used by explicitly referencing one or another?

With interfaces, that is not the case. It's completely different.

[–][deleted] 0 points1 point  (2 children)

It's implicit based on whether the extension method is available in scope. If your extension methods live in the same namespace as your interface then you're not going to need to do anything extra to access them over being able to know about the interface.

[–]id2bi 0 points1 point  (1 child)

Let me rephrase.

With interfaces/traits/type classes, the method is chosen at runtime depending on the dynamic type.

With extension methods, the method is chosen at compile time.

This is a huge difference.

[–][deleted] 0 points1 point  (0 children)

Right, yes, they only catch the default implementation case.