ISessionStateItemCollection.RemoveAt(Int32) Método

Definição

Apaga um item num índice especificado da coleção.

public:
 void RemoveAt(int index);
public void RemoveAt(int index);
abstract member RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)

Parâmetros

index
Int32

O índice do item a remover da coleção.

Exemplos

O exemplo de código seguinte mostra uma implementação do RemoveAt método. Para um exemplo de uma implementação completa da ISessionStateItemCollection interface, veja o exemplo fornecido na ISessionStateItemCollection visão geral da interface.

public void RemoveAt(int index)
{
  if (index < 0 || index >= this.Count)
    throw new ArgumentOutOfRangeException("The specified index is not within the acceptable range.");

  pItems.RemoveAt(index);
  pDirty = true;
}
 Public Sub RemoveAt(index As Integer) Implements ISessionStateItemCollection.RemoveAt 
   If index < 0 OrElse index >= Me.Count Then _
     Throw New ArgumentOutOfRangeException("The specified index is not within the acceptable range.")

   pItems.RemoveAt(index)
   pDirty = True
 End Sub

Observações

Ao implementar o RemoveAt método, deve definir a Dirty propriedade para true indicar que os valores na ISessionStateItemCollection implementação foram modificados.

A sua implementação do RemoveAt método deve lançar uma ArgumentOutOfRangeException exceção se index for menor que zero ou for igual ou maior que ICollection.Count.

Aplica-se a

Ver também