IList.Insert Method
When implemented by a class, inserts an item to the IList at the specified position.
[Visual Basic] Sub Insert( _ ByVal index As Integer, _ ByVal value As Object _ ) [C#] void Insert( int index, object value ); [C++] void Insert( int index, Object* value ); [JScript] function Insert( index : int, value : Object );
Parameters
- index
- The zero-based index at which value should be inserted.
- value
- The Object to insert into the IList.
Exceptions
| Exception Type | Condition |
|---|---|
| ArgumentOutOfRangeException | index is not a valid index in the IList. |
| NotSupportedException | The IList is read-only.
-or- The IList has a fixed size. |
Remarks
If index equals the number of items in the IList, then value is appended to the end.
In collections of contiguous elements, such as lists, the elements that follow the insertion point move down to accomodate the new element. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hashtable.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard
See Also
IList Interface | IList Members | System.Collections Namespace