Since I am repeating a DataTable , I need to check each of its DataRow objects for items in the general List row .
I found a blog post using the List Find method along with the delegate, but while this example has a separate class (Person), I'm trying to do something like the following using an instance of the string object :
List<string> lstAccountNumbers = new List<string>();
...
...
foreach (DataRow drCurrentRow in dtMyDataTable.Rows)
{
if (lstAccounts.Find(delegate(string sAccountNumber) { return sAccountNumber == drCurrentRow["AccountNumber"]; })
{
Found_DoSomething();
}
else
{
NotFound_DoSomethingElse();
}
}
However, with this syntax, I get "Can't implicitly convert the type" string "to" bool "for the if block .
Can someone clarify what I'm doing wrong, and what is the best way to accomplish what I'm trying to do?