Hi,
Why are we using @model IEnumerable<Entity_Framework_MVC.Customer> in cshtml.
and what is the difference between using List<> and the above when if should be used. Can you pls tell in simple language
Hi Rockstar8,
List is the implements from IEnumerable interface.
IEnumerable is an interface. List is a class that defines a generic collection.
IEnumerable doesn't allow random access, where as List does allow random access using integral index.
In term of performance, iterating values from IEnumerable is much faster than iterating values from a List.
Refer below links for more details.
https://stackoverflow.com/questions/3628425/ienumerable-vs-list-what-to-use-how-do-they-work
https://stackoverflow.com/questions/17448812/practical-difference-between-list-and-ienumerable
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.