C#的foreach语句问题
icod 2006-09-14 03:06:27 如下语句,names数组列表中可能包括有重复的用户名,我想用froeach偱环,只要查找到第一个匹配的用户,就执行一次更新操作,然后跳出,如何做?
string[] names = categoryRow.ManagerList.Split(str);//字段manaerlist分解
foreach (string name in names)//迭代names
{
if (name ==User.Identity.Name)
{
int rowAffected = categoryAdapter.Update(categoryID);
}
}
}
return rowAffected == 1;