Collection(Of T).Insert Method

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.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: