We use Ienumerable and Iquerable with collection to get the benefits of Linq
Difference Between IEnumerable and IQuerable :
- IEnumerable and IQuerable both are support deferred execution.
- If you use where query in Linq than In case of IEnumerable, IT will get all the data in memory and than apply where query to filter the result whereas is case of IQuerable, it apply the where query at the database level and get only the required result in memory.
So this way IQuerable perform fast as compare to IEnumerable.
Any element in a collection can be retrieved through its index property. But instead of element index, the
IEnumerator provides two abstract methods and a property to pull a particular element in a collection. And they are
See the figure. This is how it works.
Difference Between IEnumerable and IEnumerator :
- IEnumerable provide the function GetEnumerator which will give you the Enumerator as result.
- Ienumerator provide you two extra function “Reset()”, “MoveNext()” and “Current”