gnaix gnaix - 1 year ago 163
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download