Share via


ISessionStateItemCollection.RemoveAt(Int32) 方法

定義

從集合中刪除指定索引處的項目。

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

參數

index
Int32

要從集合中移除的項目之索引。

範例

下列程式碼範例示範 RemoveAt 方法的實作。 如需介面完整實作的 ISessionStateItemCollection 範例,請參閱介面概觀中 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

備註

在實作 方法時 RemoveAt ,您應該將 Dirty 屬性設定為 true ,以指出已修改實作 ISessionStateItemCollection 中的值。

如果 index 小於零或等於或大於 ICollection.Count ,則方法的實作 RemoveAt 應該擲回 ArgumentOutOfRangeException 例外狀況。

適用於

另請參閱