今天周六祝大家休息开心,我还在奋斗....
方式一:
foreach(String item in dic.keys)
{
Console.WriteLine(item);
//根据Key获取value
Console.WriteLine(dic[item]);
}
方式二:
foreach(Student inem in dic.Values)
{
//一个item就是一个学生
Console.WriteLine(item.stuName);
}
方式三:
//Key+value同时遍历
Console.WriteLine("=====明天可以休息了=====");
foreach(KeyValuePair<String,Student>item in dic)
{
Console.WriteLine(item.Key);
Console.WriteLine(item.Value.stuSalary);
}
private void BIndDate()
{
BindinSource bs=new BindinSource();
bs.DataSource=dic.Values;
dgvList.DataSource=bs;
}
Private List<Student>list;
private Dictionary<String,Student>dic;