Hi all,
how to get index of first rows that contain ‘S’ and ‘P’
The result is 0 and 4.
thanks
Hi all,
how to get index of first rows that contain ‘S’ and ‘P’
The result is 0 and 4.
thanks
Try this:
rowIndexList = yourDataTable.AsEnumerable().Select(Function(row, index) index).Where(Function(index) index > 0 AndAlso yourDataTable.Rows(index)("Column1").ToString().Contains("S") AndAlso yourDataTable.Rows(index)("Column2").ToString().Contains("P")).ToList()
Hi @supriya117
it showed {1,4,5}
Check this:
rowIndexList = yourDataTable.AsEnumerable().Select(Function(row, index) index).Where(Function(index) index > 0 AndAlso yourDataTable.Rows(index)("Column1").ToString().Contains("S") AndAlso yourDataTable.Rows(index)("Column2").ToString().Contains("P")).Take(1).ToList()
it showed {1} instead of {0,4}
HI,
How about the following?
arrIdx = dt.AsEnumerable.Where(Function(r) r(0).ToString="S" AndAlso r(1).ToString="P").Select(Function(r) dt.Rows.IndexOf(r)).ToArray
Then
arrIdx = arrIdx.Except(arrIdx.Select(Function(i) i+1)).ToArray
Note: arrIdx is Int32 array
Regards,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.