StringCollection.Item[Int32] 属性

定义

获取或设置指定索引处的元素。

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

参数

index
Int32

要获取或设置的项的从零开始的索引。

属性值

指定索引处的元素。

例外

index 小于零。

-或-

index 等于或大于 Count

注解

此属性提供使用以下语法访问集合中的特定元素的功能: myCollection[index]

StringCollection 接受 null 为有效值并允许重复元素。

C# 语言 使用此关键字来 定义索引器,而不是实现 Item[] 属性。 Visual Basic实现 Item[] 作为 default 属性,它提供相同的索引功能。

检索此属性的值是 O(1) 操作;设置属性也是 O(1) 操作。

适用于

另请参阅