Wednesday, December 22, 2010

Disposing SPWeb and SPList(SPObjects)

using (SPWeb web =SPContext.Current.Site.OpenWeb())
{
SPList Projectimages = web.Lists["ProjectPictures"];
SPQuery myQuery = new SPQuery();
SPListItemCollection Items = Projectimages.GetItems(myQuery)
}

If we use Using(){} it will automatically dispose all objects.

We need to declare and use all SPObjects in Using clause

No comments:

Post a Comment

Content Editor Webpart not showing up in SharePoint Online ------------------------------------------------------------------------------...