IList.Item Property

CollectionBase.IList.Item Property (Int32)

.NET Framework (current version)
 

Gets or sets the element at the specified index.

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

private abstract Item : 
        index:int -> Object with get, set
private override Item : 
        index:int -> Object with get, set

Parameters

index
Type: System.Int32

The zero-based index of the element to get or set.

value

The new value of the element at the specified index.

Property Value

Type: System.Object

The element at the specified index.

Exception Condition
ArgumentOutOfRangeException

index is less than zero.

-or-

index is equal to or greater than Count.

This property provides the ability to access a specific element in the collection by using the following syntax: myCollection[index].

Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation.

Notes to Implementers:

When this property is set, the methods OnValidate, OnSet, and OnSetComplete are called.

The following code example implements the CollectionBase class and uses that implementation to create a collection of Int16 objects.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft