CollectionChangedArgs<T> Struct
Definition
Section titled “Definition”Provides data for the CollectionChangedEventHandler<T> events.
public readonly struct CollectionChangedArgs<T> : IEquatable<CollectionChangedArgs<T>>Type Parameters
Section titled “Type Parameters”T
The type of the items in the collection.
Implements IEquatable<CollectionChangedArgs<T>>
Properties
Section titled “Properties”Action
Section titled “Action”Gets the action that specifies how the collection changed.
public NotifyCollectionChangedAction Action { get; }NewIndex
Section titled “NewIndex”Gets the index at which the new item was added.
public int NewIndex { get; }OldIndex
Section titled “OldIndex”Gets the index at which the old item was removed.
public int OldIndex { get; }OldItems
Section titled “OldItems”Gets the items that were added.
public ReadOnlyMemory<T> OldItems { get; }NewItems
Section titled “NewItems”Gets the items that were removed.
public ReadOnlyMemory<T> NewItems { get; }Methods
Section titled “Methods”Add(T, int)
Section titled “Add(T, int)”Creates a new instance of CollectionChangedArgs<T> with the Add action with only one item.
public static CollectionChangedArgs<T> Add(T newItem, int startingIndex)Parameters
Section titled “Parameters”newItem T
The new item that was added.
startingIndex int
The index at which the new item was added.
Returns
Section titled “Returns”CollectionChangedArgs<T>
A new instance of CollectionChangedArgs<T>.
Add(ReadOnlySpan, int)
Section titled “Add(ReadOnlySpan, int)”Creates a new instance of CollectionChangedArgs<T> with the Add action with multiple items.
public static CollectionChangedArgs<T> Add(ReadOnlySpan<T> newItems, int startingIndex)Parameters
Section titled “Parameters”newItems ReadOnlySpan<T>
The new items that were added.
startingIndex int
The index at which the new items were added.
Returns
Section titled “Returns”CollectionChangedArgs<T>
A new instance of CollectionChangedArgs<T>.
Remove(T, int)
Section titled “Remove(T, int)”Creates a new instance of CollectionChangedArgs<T> with the Remove action with only one item.
public static CollectionChangedArgs<T> Remove(T oldItem, int removedIndex)Parameters
Section titled “Parameters”oldItem T
The old item that was removed.
removedIndex int
The index at which the old item was removed.
Returns
Section titled “Returns”CollectionChangedArgs<T>
A new instance of CollectionChangedArgs<T>.
Remove(ReadOnlySpan, int)
Section titled “Remove(ReadOnlySpan, int)”Creates a new instance of CollectionChangedArgs<T> with the Remove action with multiple items.
public static CollectionChangedArgs<T> Remove(ReadOnlySpan<T> oldItems, int removedIndex)Parameters
Section titled “Parameters”oldItems ReadOnlySpan<T>
The old items that were removed.
removedIndex int
The index at which the old items were removed.
Returns
Section titled “Returns”CollectionChangedArgs<T>
A new instance of CollectionChangedArgs<T>.
Replace(T, T, int)
Section titled “Replace(T, T, int)”Creates a new instance of CollectionChangedArgs<T> with the Replace action with only one item.
public static CollectionChangedArgs<T> Replace(T oldItem, T newItem, int index)Parameters
Section titled “Parameters”oldItem T
The old item that was replaced.
newItem T
The new item that was added.
index int
The index at which the item was replaced.
Returns
Section titled “Returns”CollectionChangedArgs<T>
A new instance of CollectionChangedArgs<T>.
Replace(ReadOnlySpan, ReadOnlySpan, int)
Section titled “Replace(ReadOnlySpan, ReadOnlySpan, int)”Creates a new instance of CollectionChangedArgs<T> with the Replace action with multiple items.
public static CollectionChangedArgs<T> Replace(ReadOnlySpan<T> oldItems, ReadOnlySpan<T> newItems, int startingIndex)Parameters
Section titled “Parameters”oldItems ReadOnlySpan<T>
The old items that were replaced.
newItems ReadOnlySpan<T>
The new items that were added.
startingIndex int
The index at which the items were replaced.
Returns
Section titled “Returns”CollectionChangedArgs<T>
A new instance of CollectionChangedArgs<T>.
Clear(ReadOnlySpan, int, int)
Section titled “Clear(ReadOnlySpan, int, int)”Creates a new instance of CollectionChangedArgs<T> with the Reset action.
public static CollectionChangedArgs<T> Clear(ReadOnlySpan<T> items, int newIndex = 0, int oldIndex = 0)Parameters
Section titled “Parameters”items ReadOnlySpan<T>
The items that were cleared.
newIndex int
The index at which the items were cleared.
oldIndex int
The index at which the items were cleared.
Returns
Section titled “Returns”CollectionChangedArgs<T>
A new instance of CollectionChangedArgs<T>.
Equals(CollectionChangedArgs)
Section titled “Equals(CollectionChangedArgs)”Checks if the current instance is equal to another CollectionChangedArgs<T> instance.
public bool Equals(CollectionChangedArgs<T> other)Parameters
Section titled “Parameters”other CollectionChangedArgs<T>
The other instance to compare with.
Returns
Section titled “Returns”bool
true if the instances are equal; otherwise, false.
Equals(object?)
Section titled “Equals(object?)”Checks if the current instance is the same type as the given object and if they are equal.
public override bool Equals(object? obj)Parameters
Section titled “Parameters”obj object
The object to compare with.
Returns
Section titled “Returns”bool
true if the object is a CollectionChangedArgs<T> and is equal to the current instance; otherwise, false.
GetHashCode()
Section titled “GetHashCode()”Generates a hash code for the current instance.
public override int GetHashCode()Returns
Section titled “Returns”int
A hash code for the current instance.