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该方法时,应将属性true设置为Dirty指示已修改实现中的ISessionStateItemCollection值。

如果方法的RemoveAt实现小于零或等于或大于ICollection.Count,则应引发ArgumentOutOfRangeExceptionindex异常。

适用于

另请参阅