Sharepoint Best practice
using (SPSite site = new SPSite("http://SERVER:42204/Lists/"))
{
using (SPWeb web = site.OpenWeb())
{
SPList tasksList = web.Lists["Announcements"];
System.Data.DataTable dt;
int i = 0;
dt = tasksList.Items.GetDataTable();
foreach (System.Data.DataRow dr in dt.Rows)
{
Console.WriteLine(dr["Title"].ToString());
i++;
}
Console.WriteLine(i);
}
}
using (SPSite site = new SPSite("http://SERVER:42204/Lists/"))
{
using (SPWeb web = site.OpenWeb())
{
SPList tasksList = web.Lists["Announcements"];
System.Data.DataTable dt;
int i = 0;
dt = tasksList.Items.GetDataTable();
foreach (System.Data.DataRow dr in dt.Rows)
{
Console.WriteLine(dr["Title"].ToString());
i++;
}
Console.WriteLine(i);
}
}