SharePoint: SPList.Clear() extension method
Currently there is no good method in SharePoint for deleting all items from list. But there are solutions that need this kind of functionality. During one of my projects I wrote extension method for SPList that removes all items from it.
public static void Clear(this SPList list)
var count = list.ItemCount;
for (var i = count - 1; i >= 0; i--)
var item = list.GetItemById(i);
Public Shared Sub Clear(ByVal list As SPList)
Dim count = list.ItemCount
For i = count - 1 To 0 Step -1
Dim item = list.GetItemById(i)
Feel free to use this code. Also let me know if I can make this code better somehow.