This documentation is archived and is not being maintained.

SPListCollection.Delete Method

Windows SharePoint Services 3

Deletes the list with the specified GUID from the collection.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public virtual void Delete(
	Guid uniqueID
)

Parameters

uniqueID
Type: System.Guid
A GUID that specifies the list to delete.

The following code example deletes the list with a specified name from the collection of lists in a site.

using (SPWeb oWebsite = SPContext.Current.Site.AllWebs["Website_Name"])
{
    SPListCollection collLists = oWebsite.Lists;
    SPList oList = collLists["List_Name"];
    System.Guid guidListID = oList.ID;
    collLists.Delete(guidListID);
}
NoteNote

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Best Practices: Using Disposable Windows SharePoint Services Objects.

Show: