Would this code cause an SPList object to leak? It's enclosed in a Using statement but that's in a sub routine.
String site = "http://server/sites/site";
foreach (string s in OutputListField(GetList(site, "Documents")))
{
Response.Output.WriteLine(s + "<br />");
}
protected string[] OutputListField(SPList list)
{
if (list == null) throw new ArgumentNullException();
string[] propertyValue = new string[list.Items.Count];
int i = 0;
foreach (SPListItem item in list.Items)
{
propertyValue[i] = item["Name"].ToString();
i ++;
}
return propertyValue;
}
protected SPList GetList(string site, string listname)
{
SPList list = null;;
using (SPSite mySite = new SPSite(site))
{
using (SPWeb myWeb = mySite.OpenWeb())
{
list = myWeb.Lists[listname];
}
if (list == null)
{
throw new ArgumentNullException();
}
return list; **"Would this cause the SPList to leak?"**
}
}
}