StringCollection.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.

属性值

Object

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

实现

例外

index 小于零。index is less than zero.

- 或 --or- index 等于或大于 Countindex is equal to or greater than Count.

注解

此方法提供了使用以下语法访问集合中的特定元素的功能: myCollection[index]This method provides the ability to access a specific element in the collection by using the following syntax: myCollection[index].

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

StringCollection 接受 null 作为有效值,并允许重复元素。StringCollection accepts null as a valid value and allows duplicate elements.

检索此属性的值是一个 O (1) 操作;设置属性也是 O (1) 操作。Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation.

适用于

另请参阅