I think the
Select
method of
DataTable
with
IN
clause in the filter expression can be used to return
Rows
of which the required
column
value matches any of the strings given in the
IN
clause as shown below:
string s1="emp";
string s2="student";
string s3="project";
DataRow[] foundRows = names.Select(string.Format(
"Name IN ('{0}','{1}','{2}')",
s1,s2,s3),string.Empty,
DataViewRowState.CurrentRows);
Console.WriteLine (foundRows.Length);
foreach(DataRow row in foundRows)
Console.WriteLine (row["Name"].ToString());
Alternatively LINQ can be used as follows
string s1="emp";
string s2="student";
string s3="project";
var stringsToFind = new List<string>(){s1,s2,s3};
var foundStrings = names.AsEnumerable().Where (n => stringsToFind
.Any (stf => stf.Equals(n.Field<string>("Name"),
StringComparison.InvariantCultureIgnoreCase)))
.GroupBy (n => n.Field<string>("Name"))
.Select (n => string.Format("{0,-15}-->{1,3}",
n.Key,n.Count ()));
foreach (string name in foundStrings)
Console.WriteLine (name);