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.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- index
- Type: System.Int32
The zero-based index at which item should be inserted.
- item
- Type: TItem
The object to insert.
| Exception | Condition |
|---|---|
| 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.