Class NotNullCollection<T>
Represents a collection that does not allow null elements.
public class NotNullCollection<T> : BaseCollection<T>, IList<T>, ICollection<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged
Type Parameters
T
The type of elements in the collection.
- Inheritance
-
Collection<T>NotNullCollection<T>
- Implements
-
IList<T>ICollection<T>IEnumerable<T>
Remarks
This collection ensures that all added items are non-null, preventing accidental null references.
Constructors
- NotNullCollection()
Initializes a new instance of the NotNullCollection<T> class.
- NotNullCollection(List<T>)
Initializes a new instance of the collection as a wrapper for the specified list.
Properties
- ThrowOnNullAdd
Gets or sets a value indicating whether an ArgumentNullException should be thrown on an attempt to add a
null
value to the collection.