Why does List implement IReadOnlyList in .NET 4.5?

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

Why does List implement IReadOnlyList in .NET 4.5?

List isn\'t read only...

7条回答
  •  爱一瞬间的悲伤
    2020-11-29 12:50

    Isn't it true that the code running IReadOnlyList(Of T) calls to an object that implements that interface is usually running the same thread of execution. That prevents the object from being altered by itself, unless its running on a different thread of execution, but for that situation we have synchronization calls to solve that.

提交回复
热议问题