Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • Adding instance methods to classes that implement the interface isn't going to work because the consumer won't see them unless they are working with the implementing class itself. If all you have is an IComponent then the compiler will use the extension every time. Commented Nov 28, 2019 at 12:13
  • @Corey did you every used myList.First()? or you always cast variables like ((IEnumerable<int>)myList).First() before using LINQ methods for example? (Granted for LINQ this is actually feature...) Commented Nov 28, 2019 at 20:44
  • Sure, when I have a List<int>. When I have an IEnumerable<int> then I call the extension because that's all I have. I don't bother with trying to figure out what implementation I have because the extension handles that better in most cases. Commented Nov 28, 2019 at 22:35