ASP.NET MVC 2 to view: IList or List?

Should I go back from the model to view the object IList<T>or List<T>? I would iterate over the Model collection and display the results in an ASP.NET MVC 2 view.

+3
source share
3 answers

I like to keep things as general as possible to help with Mocking during testing later.

If you just repeat the assembly for the loop foreach, I would probably use IEnumerable<T>one since you don't need functionality IList<T>.

If you need functionality from IList<T>(e.g. iterate over a collection in a loop forusing an index) then use IList<T>.

, List<T>.

+6

, , foreach, IEnumerable<T>.

+1

Curious; IList can help scoff if you are going to test your views, but it really doesn’t matter ...

0
source

Source: https://habr.com/ru/post/1771530/


All Articles