gnaix gnaix - 5 months ago 55
C# Question

Why NotifyCollectionChangedEventArgs.NewItems Property is a list?

From the above link, it says this property

Gets the list of new items involved in the change.

Since the collection only supports Add,Remove, Move for a single element, why this property returns a IList interface?


A collection type that implements this interface could have a method that adds multiple items in a single call, similar to the List<T>.AddRange(IEnumerable<T>) method.

The fact that ObservableCollection doesn't have such a method doesn't mean other collection types couldn't. However, ObservableCollection will always pass only 1 element (or null) to the NewItems collection of a NotifyCollectionChangedEventArgs.