Why is ReadOnlyObservableCollection.CollectionChanged not public?

后端 未结 8 2107
心在旅途
心在旅途 2021-01-31 06:50

Why is ReadOnlyObservableCollection.CollectionChanged protected and not public (as the corresponding ObservableCollection.CollectionChanged is)?

What is the use of a col

8条回答
  •  一生所求
    2021-01-31 07:31

    I know this post is old, however, people should take their time to understand the patterns used in .NET before commenting. A read only collection is a wrapper on an existing collection that prevents consumers from modifying it directly, look at ReadOnlyCollection and you will see that it is a wrapper on a IList which may or may not be mutable. Immutable collections are a different matter and are covered by the new immutable collections library

    In other words, read only is not the same as immutable!!!!

    That aside, ReadOnlyObservableCollection should implicitly implement INotifyCollectionChanged.

提交回复
热议问题