Export (0) Print
Expand All

SPListCollection.Delete method

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


Type: System.Guid

A GUID that specifies the list to delete.

This method marks the collection as changed.

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;

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 Disposing Objects.

© 2014 Microsoft