List, IList, IEnumerable, IQueryable, ICollection, which is most flexible return type?

前端 未结 3 632
感动是毒
感动是毒 2020-11-30 21:34

I\'ve seen this question posted here previously but I\'m not satisfied that I understand the complete ramifications. The problem is what return type should a data layer that

3条回答
  •  一生所求
    2020-11-30 22:03

    1) It's best to return an IList so that the results can be put into any object that implements that interface, rather than forcing the caller into using a List. For example, the caller might wish to have the results returned to an ArrayList, this wouldn't be possible if you had the results returned to a List. ArrayList doesn't inherit from List, but it does implement IList.

提交回复
热议问题