Export (0) Print
Expand All

Collection<T>.Insert Method

Inserts an element into the Collection<T> at the specified index.

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

public void Insert(
	int index,
	T item
)

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 null for reference types.

Implements

IList<T>.Insert(Int32, T)

ExceptionCondition
ArgumentOutOfRangeException

index is less than zero.

-or-

index is greater than Count.

Collection<T> accepts null 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<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:
© 2014 Microsoft