ISessionStateItemCollection.RemoveAt(Int32) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
删除集合中指定索引处的项。
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异常。
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈