Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Assuming I already have the list object, is there some difference between calling its Delete extension as opposed to removing it from the Lists collection? Why would I ever choose the latter?

share|improve this question
add comment

1 Answer 1

Basically both methods do the same thing, but SPList.Delete() is a method of SPList object, where SPWeb.Lists.Delete(guid) is a method of SPListCollection object as SPWeb.Lists represents a SPListCollection object, so you can easily understand, in most of the cases you will find SPList.Delete() suitable to your need - because it is straightforward and also efficient as you dont get the collection first (negligible though), i tend to always follow the first one

It's hard to find cases where you may find SPWeb.Lists.Delete(guid) more suitable, one possible cases (highly unlikely situation) - say you have a list of list-guids which you need to delete, then rather than getting SPList reference for each and every list you can just delete the list using this method

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.