IEnumerable vs T[]

前端 未结 7 1324
天命终不由人
天命终不由人 2021-01-07 20:43

I just realize that maybe I was mistaken all the time in exposing T[] to my views, instead of IEnumerable.

Usually, for this kind

7条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-07 21:05

    T[] (one sized, zero based) also implements ICollection and IList with IEnumerable.

    Therefore if you want lesser coupling in your application IEnumerable is preferable. Unless you want indexed access inside foreach.

提交回复
热议问题