InsertItem Method
Collapse the table of content
Expand the table of content

KeyedCollection<TKey, TItem>.InsertItem Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Inserts an element into the KeyedCollection<TKey, TItem> at the specified index.

Namespace:  System.Collections.ObjectModel
Assembly:  mscorlib (in mscorlib.dll)

protected override void InsertItem(
	int index,
	TItem item
)

Parameters

index
Type: System.Int32
The zero-based index at which item should be inserted.
item
Type: TItem
The object to insert.

ExceptionCondition
ArgumentOutOfRangeException

index is less than 0.

-or-

index is greater than Count.

If index is equal to Count, item is added to the end of the KeyedCollection<TKey, TItem>.

This method is an O(n) operation, where n is Count.

Notes for Implementers

Override this method to provide customized behavior for the Add and Insert methods, inherited from the Collection<T> generic class.

Call the base class implementation of this method to insert the item into the underlying collection and to update the lookup dictionary.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft