Follwoing Code help yoiu to automaticaly Dispose SPSite & SPWeb Object
this is because SPSite & SPWeb implements IDisposable Interface
you can use "Using" for disposing other objects which implements IDisposable Interface.
using(SPSite oSPsite = new SPSite("http://server"))
{
using(SPWeb oSPWeb = oSPSite.OpenWeb())
{
str = oSPWeb.Title;
str = oSPWeb.Url;
}
}
{
using(SPWeb oSPWeb = oSPSite.OpenWeb())
{
str = oSPWeb.Title;
str = oSPWeb.Url;
}
}
No comments:
Post a Comment