Why does List implement IReadOnlyList in .NET 4.5?

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

Why does List implement IReadOnlyList in .NET 4.5?

List isn\'t read only...

相关标签:
7条回答
  • 2020-11-29 12:51

    Interfaces only describes functionality which will be implemented. It does not describe functionality which will not be implemented. IReadOnlyList is therefor an incorrect interface name, as it cannot dictate that write functionality will not be written.

    The methods/functions of describe that you can read the contents of the list. The interface should have been IReadableList instead of IReadOnlyList.

    0 讨论(0)
提交回复
热议问题