Ienumerable

IEnumerable, and its generic counterpart IEnumerable<T> are .NET interfaces for iterating (or enumerating) through a collection of items.

Ilist

Non-generic interface in .NET for collections of objects which can be accessed individually by index



Functionality iteration only

Example

"You need to use tolist to convert it from ienumerable because the ilist interface supports more functionality than the ienumerable interface"

from question  

How to cast to a List<IEnumerable<XElement>>

"Simply ienumerable gives you iteration only;icollection adds counting and ilist then gives richer functionality including find add and remove elements by index or via lambda expressions"

from question  

Most efficient collection for storing data from LINQ to Entities?

Specific functions

Example

"An ienumerable is less specific than an ilist"

from question  

Why return Interfaces eg IEnumerable, IList - example of refactoring

"Ienumerable is less specific than ilist"

from question  

When to use IList and when to use List

"Ienumerable is less specific than an ilist that is ilist has functions that ienumerable does not"

from question  

Should I return an IEnumerable or IList?

Abstract method collections

Example

"Another suggestion change you to because you can keep an extension method for more collections because the ienumerable is more abstract than ilist"

from question  

How to using class with static method in C#?

"Ienumerable is more abstract and is generally preferred to list or ilist if possible"

from question  

List<> Versus IEnumerable<>, when defining a new class or a new viewmodel class

Others

Example

Another difference in case of ef is that the ienumerable is not executing the query to the db untill you really enumerate the list;while the ilist will execute the query and fetch the items in memory

from question  

EF ICollection Vs List Vs IEnumerable Vs IQueryable

Thus ilist is more than ienumerable and you won t be able to get away with it

from question  

Conversion of IEnumerable<T> to IList

Ilist is stronger in that ilist makes more guarantees than ienumerable

from question  

Accept the weakest, return the strongest. But why?

By ienumerable;therefore ilist is the more strict conversion and is therefore selected

from question  

Get best matching overload from set of overloads

Yes i understand that ienumerable is much more lighter rather than ilist but anyway there is a lot situations where we need to have ilist instead of ienumerable and in this approach we need to cast ienumerable to ilist isn t it

from question  

EF 4.0 Repository pattern IList<T> or IEnumerable<T>

The reason why this doesn t work specifically is because ilist is more specialized than ienumerable

from question  

Error due to concrete class and interface not having matching return types for IEnumerable<T> and List<T>

The ienumerable component returns an ilist which is more generic to work with

from question  

How to create a generic method in C# that's all applicable to many types - ints, strings, doubles etc

And since ilist inherits from ienumerable you can call where on both interfaces calling where on a ilist actually calls the ienumerable.where extension method;so in both cases the same base method is called and the type of the resulting value will be an ienumerable not an ilist when applied to a list

from question  

What is "further filtering" for iterators?

Ienumerable is less specific than ilist ilist implements ienumerable so unless you want something specific from ilist such as .count as you suggest or perhaps add delete etc i d use ienumerable

from question  

What should I use an IEnumerable or IList?

Ienumerable basically only supports iterating over the results contained in the collection;ilist is more specific and allows you to

from question  

IEnumerable vs List

In the older versions of nop commerce i have seen that they always use to return but now in the latest versions most of the view models are returned in ilist.i know with ilist its good to work with abstraction instead of concrete type list but then ienumerable is much better because everything derives from it

from question  

What are the best practices to returns models(DTO) from a method?

I suspect the main problem you are encountering is the fact that indexing into ienumerable is not possible;i would guess that ilist may be a more appropriate interface for the items which would allow greater control over the items in general

from question  

How do I get property of an Ienumerable in the view?

Back to Home
Data comes from Stack Exchange with CC-BY-SA-4.0