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?


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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