LINQ | Filter DataTable | Get Matched Row Index

Hey @Arup,

Here is the solution

DT_Test.Rows.IndexOf((DT_Test.AsEnumerable.Where(function(row) (row(“col2”).ToString.Equals(“String1”) or row(“col2”).ToString.Equals(“String2”)) and (row(“col3”).ToString.Equals(“String1”) or row(“col3”).ToString.Equals(“String2”))).First))

This will find the index of only the first match, if you want for every match then you can workaround by a loop or another nested LINQ.

Meanwhile, you can also even try Select statement to achieve the same.

Let me know for any queries.

Thanks

3 Likes