ISessionStateItemCollection.RemoveAt(Int32) Méthode

Définition

Supprime un élément de la collection au niveau de l'index spécifié.

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

Paramètres

index
Int32

Index de l'élément à supprimer de la collection.

Exemples

L'exemple de code suivant illustre une implémentation de la méthode RemoveAt. Pour obtenir un exemple d’implémentation complète de l’interface ISessionStateItemCollection , consultez l’exemple fourni dans la vue d’ensemble de l’interface ISessionStateItemCollection .

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

Remarques

Dans l’implémentation de la RemoveAt méthode, vous devez définir la Dirty propriété pour true indiquer que les valeurs de l’implémentation ISessionStateItemCollection ont été modifiées.

Votre implémentation de la RemoveAt méthode doit lever une ArgumentOutOfRangeException exception si index elle est inférieure à zéro ou égale ou supérieure ICollection.Countà .

S’applique à

Voir aussi