Why does List implement IReadOnlyList in .NET 4.5?

后端 未结 7 1531
离开以前
离开以前 2020-11-29 11:56

Why does List implement IReadOnlyList in .NET 4.5?

List isn\'t read only...

7条回答
  •  生来不讨喜
    2020-11-29 12:48

    The fact that it implements the interface doesn't mean it is read-only. But because it implements the interface you can now pass it to methods that expect an IReadOnlyList. So the way to look at it, is that it implements the read-only list interface...along with some write methods.

提交回复
热议问题