Why should I use List<T> over IEnumerable<T>?
Posted
by
Rowan Freeman
on Programmers
See other posts from Programmers
or by Rowan Freeman
Published on 2013-04-06T03:15:39Z
Indexed on
2013/11/03
22:17 UTC
Read the original article
Hit count: 324
In my ASP.net MVC4 web application I use IEnumerables, trying to follow the mantra to program to the interface, not the implementation.
Return IEnumerable(Of Student)
vs
Return New List(Of Student)
People are telling me to use List and not IEnumerable, because lists force the query to be executed and IEumerable does not.
Is this really best practice? Is there any alternative? I feel strange using concrete objects where an interface could be used. Is my strange feeling justified?
© Programmers or respective owner