Compartilhar via


Delete Method

The Delete method of the SPListItemCollection class deletes the item at the specified index in the collection.

Parameters

iIndex   A 32-bit integer that specifies the index.

Remarks

The Delete method deletes an item by its index in the collection. To delete an item by its ID, use the DeleteItemByID method.

This method returns an ArgumentOutOfRangeException exception if the specified index is outside the valid range of indices for the collection.

Example

The following code example deletes from the specified list any items in which an integer field value is less than 70 or a text field value equals None.

The For loop in the example counts downward (i--) instead of upward (i++) since items are being deleted and the number of items decreases with each increment.

This example requires using directives (Imports in Visual Basic) for both the Microsoft.SharePoint and Microsoft.SharePoint.WebControls namespaces.

Requirements

Platforms: Microsoft Windows Server 2003

Security: Code Access Security