Insert Method

Collection<T>.Insert Method (Int32, T)


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


Type: System.Int32

The zero-based index at which item should be inserted.

Type: T

The object to insert. The value can be null for reference types.

Exception Condition

index is less than zero.


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.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft