StringCollection.Item[Int32] Propriedade

Definição

Obtém ou define o elemento no índice especificado.Gets or sets the element at the specified index.

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

Parâmetros

index
Int32

O índice baseado em zero da entrada a ser obtida ou definida.The zero-based index of the entry to get or set.

Valor da propriedade

String

O elemento no índice especificado.The element at the specified index.

Exceções

index é menor que zero.index is less than zero.

- ou --or- index é igual a ou maior que Count.index is equal to or greater than Count.

Comentários

Esta propriedade fornece a capacidade de acessar um elemento específico na coleção usando a seguinte sintaxe: myCollection[index].This property provides the ability to access a specific element in the collection by using the following syntax: myCollection[index].

StringCollection aceita null como um valor válido e permite elementos duplicados.StringCollection accepts null as a valid value and allows duplicate elements.

A linguagem C# usa a palavra-chave this para definir os indexadores em vez de implementar a Item[] propriedade.The C# language uses the this keyword to define the indexers instead of implementing the Item[] property. Visual Basic implementa Item[] como uma propriedade padrão, que fornece a mesma funcionalidade de indexação.Visual Basic implements Item[] as a default property, which provides the same indexing functionality.

A recuperação do valor dessa propriedade é uma operação O (1); a definição da propriedade também é uma operação O (1).Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation.

Aplica-se a

Confira também