Collection<T>.IList.Item[Int32] 属性

定义

获取或设置指定索引处的元素。Gets or sets the element at the specified index.

property System::Object ^ System::Collections::IList::Item[int] { System::Object ^ get(int index); void set(int index, System::Object ^ value); };
object System.Collections.IList.Item[int index] { get; set; }
member this.System.Collections.IList.Item(int) : obj with get, set
 Property Item(index As Integer) As Object Implements IList.Item

参数

index
Int32

要获取或设置的元素的从零开始的索引。The zero-based index of the element to get or set.

属性值

指定索引处的元素。The element at the specified index.

实现

例外

index 不是 IList 中的有效索引。index is not a valid index in the IList.

已设置属性,且 value 属于不能对 IList 赋值的类型。The property is set and value is of a type that is not assignable to the IList.

注解

可以使用下面的语法通过此属性访问集合中的特定元素:myCollection[index]This property provides the ability to access a specific element in the collection by using the following syntax: myCollection[index].

该C#语言使用this关键字来定义索引器,而不是实现 IList.Item[Int32] 属性。The C# language uses the this keyword to define the indexers instead of implementing the IList.Item[Int32] property. Visual Basic 将 IList.Item[Int32] 实现为默认属性,该属性提供相同的索引功能。Visual Basic implements IList.Item[Int32] as a default property, which provides the same indexing functionality.

检索此属性的值的运算复杂度为 O (1);设置属性也是 O (1)操作。Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation.

适用于