I am creating a tree and I want to search if an NIC is present in the list or not but when I do list.Exists(nic)
it gives error please help
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);
}
}
}
}
Although your question misses a lot of information, I think what you need is:
if (broList.Exists(p=>p.NIC==nic))