我正在创建一个树,我想搜索列表中是否存在NIC但是当我list.Exists(nic)
时它会出错,请帮助
List<PeopleInvolved> broList = new List<PeopleInvolved>();
List<PeopleInvolved> allInvolved = new List<PeopleInvolved>();
string value = "null";
foreach (var person in allInvolved)
{
conn.Open();
nic = person.NIC;
using (dr3 = cmd5.ExecuteReader())
{
if (!dr3.Read())
{
dr3.Close();
if (broList.Exists(nic))
{
valueTable.Add(nic, 6);
}
}
}
}
答案 0 :(得分:0)
虽然你的问题遗漏了很多信息,但我认为你需要的是:
if (broList.Exists(p=>p.NIC==nic))