Insert Method

Collection(Of T).Insert 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 Collection(Of T) at the specified index.

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

'Declaration
Public Sub Insert ( _
	index As Integer, _
	item As T _
)

Parameters

index
Type: System.Int32
The zero-based index at which item should be inserted.
item
Type: T
The object to insert. The value can be Nothing for reference types.

Implements

IList(Of T).Insert(Int32, T)

ExceptionCondition
ArgumentOutOfRangeException

index is less than zero.

-or-

index is greater than Count.

Collection(Of T) accepts Nothing as a valid value for reference types and allows duplicate elements.

If index is equal to Count, item is added to the end of Collection(Of T).

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

Notes to Inheritors

Derived classes can override InsertItem to change the behavior of this method.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft