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.
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.
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.
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.