c# foreach语句循环取各对象

1.取下拉框的值

foreach(ListItem Item in DropDownListDepartment.Items)
{}
2.
foreach(DataRow dr in dt.Rows)
            {}
3 foreach (GridViewRow row in GV.Rows)
{}
4 ArrayList selectedUsers=GetSelected();           
foreach(string loginName in selectedUsers)
{
}
5 hashtable 
Hashtable queryItems=new Hashtable();
foreach(DictionaryEntry item in queryItems)
{
}

DataRow dr=db.GetDataRow(sql);
for(int i=0;i<dr.ItemArray.Length;i++)
    {

你可能感兴趣的:(foreach)