SPListCollection.Delete Method
Deletes the list with the specified GUID from the collection.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
Public Overridable Sub Delete ( _
uniqueID As Guid _
)
'Usage
Dim instance As SPListCollection
Dim uniqueID As Guid
instance.Delete(uniqueID)
public virtual void Delete(
Guid uniqueID
)
Parameters
uniqueID
Type: System.GuidA GUID that specifies the list to delete.
Remarks
This method marks the collection as changed.
Examples
The following code example deletes the list with a specified name from the collection of lists in a site.
Dim site As SPWeb =
SPControl.GetContextSite(Context).AllWebs("Site_Name")
Dim lists As SPListCollection = site.Lists
Dim list As SPList = lists("List_Name")
Dim listGuid As System.Guid = list.ID
lists.Delete(listGuid)
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);
}
Note
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.