Enhanced C#
Language of your choice: library documentation
|
Encapsulates a ListChanged event that notifies listeners that a list has changed, such as when items are added or removed or the whole list is refreshed. More...
Encapsulates a ListChanged event that notifies listeners that a list has changed, such as when items are added or removed or the whole list is refreshed.
T | Type of items in the list |
TCollection | Type of the first argument of the event |
This approach to change notification is more lightweight than the standard INotifyCollectionChanged interface because that interface sends both a list of new items and a list of old items, so many changes require a pair of temporary objects to be created that hold the two lists of items.
In contrast, the ListChanged event includes only one list that specifies the set of new items. No list of old items is provided.
An optimization is available when only a single item is being added or changed. In that case, the collection class should create a lightweight read-only single-item list by calling ListExt.Single<T>(T). Such a list has less overhead than List<T> and the same overhead as an array of one item.