Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Should items in SPSite.AllWebs be Disposed?

$
0
0

Hello,

Does this loop follows best practices when it disposes the items in SPSite.AllWebs?

foreach (SPWeb web in site.AllWebs)
{
try
{
// Do something
}
finally
{
if (web != null)
{
web.Dispose();
}
}
}


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>