LINQ methods - extension methods?

I want to understand LINQ and have done some research on this and have discovered that IEnumerable and IQueryable have LINQ methods. However, when I look at the documentation for these types, I do not see any LINQ methods.

Are LINQ method extension methods inserted into IEnumerable/IQueryable at runtime, and if so, why?

+7
source share
1 answer

Adding methods to IEnumerable means that all types that come from IEnumerable would have to implement them themselves. Now, using extension methods, we can sort the additions of implementations to interfaces.

Another side effect will be that code written in .NET 2.0 will still compile with 3.0 when Linq was introduced. Otherwise, if you implemented IEnumerable somewhere in your project, you would also have to implement all the new methods in the interface.

LINQ methods for Linq To Objects are defined in the Enumerable class.

In addition, LINQ looks for methods declared using specific syntax and is not an interface or class. You can find the Edulinq Jon Skeet series.

MSDN link to extension methods.

+15
source

All Articles