非淡泊无以明志,非宁静无以致远 -心静如止水,动于静

For VS. Foreach in MOSS

Doing the project, I noticed, the performance For steatment is lower than Foreach especially loop List Control.

 

int count = list.ItemCount;
for (int i = 0; i <>count, i ++)
{
//  it is very low performance

SPListItem item = list.Items[i];
...
}

SPListItemCollection items = list.Items;

// nice habit
foreach (SPListItem item in Items)
{
...
}

posted @ 2010-04-08 17:17  烟雨客  阅读(181)  评论(0编辑  收藏  举报