ISessionStateItemCollection.RemoveAt(Int32) Metoda

Definice

Odstraní položku v zadaném indexu z kolekce.

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

Parametry

index
Int32

Index položky, kterou chcete odebrat z kolekce.

Příklady

Následující příklad kódu ukazuje implementaci RemoveAt metody. Příklad úplné implementace ISessionStateItemCollection rozhraní najdete v příkladu uvedeném v přehledu ISessionStateItemCollection rozhraní.

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

Poznámky

Při implementaci RemoveAt metody byste měli nastavit Dirty vlastnost tak, aby true indikovala hodnoty v ISessionStateItemCollection implementaci byly změněny.

RemoveAt Implementace metody by měla vyvolat ArgumentOutOfRangeException výjimku, pokud index je menší než nula nebo je rovna nebo větší než ICollection.Count.

Platí pro

Viz také