I have an issue around using SPListItem.Delete. I am fetching some list items (less than 20) and looping through them using a for loop. In each iteration of the loop, I retrieve a SPListItem using SPListItemCollection.GetItemByID method. And then I execute a Delete(). However, it only deletes half the items.
Can some one please help?
Code follows:
SPListItemCollection listItems = Get_Items();
for (int i=0; i<listItems.Count; i++)
{
SPListItem currentListItem = listItems.GetItemById(listItems[i].ID);
currentListItem.Delete();
}
Thanks,