IList<T>.Item[Int32] 属性

定义

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

public:
 property T default[int] { T get(int index); void set(int index, T value); };
public T this[int index] { get; set; }
member this.Item(int) : 'T with get, set
Default Public Property Item(index As Integer) As T

参数

index
Int32

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

属性值

T

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

异常

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

设置了该属性,但 IList<T> 为只读。The property is set and the IList<T> is read-only.

注解

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

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

适用于

另请参阅