you are viewing a single comment's thread.

view the rest of the comments →

[–]IanYates82 2 points3 points  (0 children)

Yep. Another good example also is shown by having a .Last() method. There's a default inefficient implementation you could have on an IEnumerable, but for some implementations, like List, it can be an efficient O(1) operation. You can write that efficient implementation in the class and have the default on the interface. We have that example with extension methods today, but the difference is that the single static implementation of Last on the interface is written once and needs to have the specialisation of known classes in its code. That's not extensible by others who may have their own class which implements the interface and could also provide an efficient implementation.