IEnumerable as return type

前端 未结 10 2314
轮回少年
轮回少年 2020-12-01 10:41

Is there a problem with using IEnumerable as a return type? FxCop complains about returning List (it advises returning Coll

10条回答
  •  孤街浪徒
    2020-12-01 11:09

    One important aspect is that when you return a List you are actual returning a reference. That makes it possible for a caller to manipulate your list. This is a common problem—for instance, a Business layer that returns a List to a GUI layer.

提交回复
热议问题