urmila gupta
what is the difference between IList and IEnumerable
Posted by urmila gupta in C# Language on Sep 13, 2012
  • 0
  • 11
  • 5074
Do you know the answer for this question? Post it below.
Guest
Posted by Narayan Pramar on Jan 05, 2013
  • 0

IEnumerable provides only minimal "iterable" functionality. You can traverse the sequence, but that's about it. This has disadvantages
-->> for example, it is very inefficient to count elements using IEnumerable, or to get the nth element -->> but it has advantages too -->> for example, an IEnumerable could be an endless sequence, like the sequence of primes.IList is an interface which abstracts list functionality (count, add, remove, indexer access) away from the various concrete classes such as List, BindingList, ObservableCollection, etc.

Posted by Narayan Pramar on Jan 05, 2013
  • 0


IEnumerable provides only minimal "iterable" functionality. You can traverse the sequence, but that's about it. This has disadvantages
-->> for example, it is very inefficient to count elements using IEnumerable, or to get the nth element -->> but it has advantages too -->> for example, an IEnumerable could be an endless sequence, like the sequence of primes.

IList is an interface which abstracts list functionality (count, add, remove, indexer access) away from the various concrete classes such as List, BindingList, ObservableCollection, etc.

Posted by Narayan Pramar on Jan 05, 2013
  • 0


IEnumerable provides only minimal "iterable" functionality. You can traverse the sequence, but that's about it. This has disadvantages
-->> for example, it is very inefficient to count elements using IEnumerable, or to get the nth element -->> but it has advantages too -->> for example, an IEnumerable could be an endless sequence, like the sequence of primes.

IList is an interface which abstracts list functionality (count, add, remove, indexer access) away from the various concrete classes such as List, BindingList, ObservableCollection, etc.

Posted by shaik azhar on Sep 20, 2012
  • 0

IEnumerable is an open set. If you research the "yield" statement you'll find that calling "ToList()" is only one way to populate an enumerable list. You can create enumerables on the fly and use the iterator state machine to continue to provide values.

IList, on the other hand, is a finite set. The key difference is that IList provides a count so you have knowledge beforehand how large the list is.

The purpose of enumerable is to take a very large set and enumerate over the set without actually having to load all of the values or elements in the set. The list on the other hands must account for all elements up front.

In your example both situations work pretty much the same because you are casing to a list and then either exposing the list directly, or exposing the enumerator to the list.

Posted by shaik azhar on Sep 20, 2012
  • 0

IEnumerable is an open set. If you research the "yield" statement you'll find that calling "ToList()" is only one way to populate an enumerable list. You can create enumerables on the fly and use the iterator state machine to continue to provide values.

IList, on the other hand, is a finite set. The key difference is that IList provides a count so you have knowledge beforehand how large the list is.

The purpose of enumerable is to take a very large set and enumerate over the set without actually having to load all of the values or elements in the set. The list on the other hands must account for all elements up front.

In your example both situations work pretty much the same because you are casing to a list and then either exposing the list directly, or exposing the enumerator to the list.

Posted by shaik azhar on Sep 20, 2012
  • 0

IEnumerable is an open set. If you research the "yield" statement you'll find that calling "ToList()" is only one way to populate an enumerable list. You can create enumerables on the fly and use the iterator state machine to continue to provide values.

IList, on the other hand, is a finite set. The key difference is that IList provides a count so you have knowledge beforehand how large the list is.

The purpose of enumerable is to take a very large set and enumerate over the set without actually having to load all of the values or elements in the set. The list on the other hands must account for all elements up front.

In your example both situations work pretty much the same because you are casing to a list and then either exposing the list directly, or exposing the enumerator to the list.

Posted by shaik azhar on Sep 20, 2012
  • 0

IEnumerable is an open set. If you research the "yield" statement you'll find that calling "ToList()" is only one way to populate an enumerable list. You can create enumerables on the fly and use the iterator state machine to continue to provide values.

IList, on the other hand, is a finite set. The key difference is that IList provides a count so you have knowledge beforehand how large the list is.

The purpose of enumerable is to take a very large set and enumerate over the set without actually having to load all of the values or elements in the set. The list on the other hands must account for all elements up front.

In your example both situations work pretty much the same because you are casing to a list and then either exposing the list directly, or exposing the enumerator to the list.

Posted by shaik azhar on Sep 20, 2012
  • 0

IEnumerable is an open set. If you research the "yield" statement you'll find that calling "ToList()" is only one way to populate an enumerable list. You can create enumerables on the fly and use the iterator state machine to continue to provide values.

IList, on the other hand, is a finite set. The key difference is that IList provides a count so you have knowledge beforehand how large the list is.

The purpose of enumerable is to take a very large set and enumerate over the set without actually having to load all of the values or elements in the set. The list on the other hands must account for all elements up front.

In your example both situations work pretty much the same because you are casing to a list and then either exposing the list directly, or exposing the enumerator to the list.

Posted by shaik azhar on Sep 20, 2012
  • 0

IEnumerable is an open set. If you research the "yield" statement you'll find that calling "ToList()" is only one way to populate an enumerable list. You can create enumerables on the fly and use the iterator state machine to continue to provide values.

IList, on the other hand, is a finite set. The key difference is that IList provides a count so you have knowledge beforehand how large the list is.

The purpose of enumerable is to take a very large set and enumerate over the set without actually having to load all of the values or elements in the set. The list on the other hands must account for all elements up front.

In your example both situations work pretty much the same because you are casing to a list and then either exposing the list directly, or exposing the enumerator to the list.

Posted by nimesh singh on Sep 18, 2012
  • 0



There is a major difference.

IEnumerable is an open set. If you research the "yield" statement you'll find that calling "ToList()" is only one way to populate an enumerable list. You can create enumerables on the fly and use the iterator state machine to continue to provide values.

IList, on the other hand, is a finite set. The key difference is that IList provides a count so you have knowledge beforehand how large the list is.

The purpose of enumerable is to take a very large set and enumerate over the set without actually having to load all of the values or elements in the set. The list on the other hands must account for all elements up front.

In your example both situations work pretty much the same because you are casing to a list and then either exposing the list directly, or exposing the enumerator to the list.

Posted by Pravin Patil on Sep 14, 2012
  • 0

The simplest answer to this question is - IEnumerable allows only iteration on it's members(As in For...Each), while IList allows add/remove along with Iteration.


Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS

PRIVACY POLICY | TERMS & CONDITIONS | SITEMAP | CONTACT US | ABOUT US | REPORT ABUSE
2014© C# Corner. All contents are copyright of their authors.