Datatable: Loop every 8th row

Hi,

For my data table, I only want to loop the 0th, 8th, 16th, 24th,…

How do I set up the If condition? Thank you

DT1.Rows.IndexOf(row) mod 2=0

Hi

Or is there a way to set up a list for (0, 8,16,…), and I only loop if the Datatable Row is equal any of the number in the list?
If condition:

DT1.Rows.IndexOf(row) =list

can be done with the help of Mod 8 and Enumerable Range
e.g. Enumerable.Range(0,yourDataTable.Rows.Count).Where(Function (x) x Mod 8 = 0).toList
is creating a sequence of 0,8,16 …
Example:


and can be used for discrete row acces by index DataTableVar.Row(myMod8Index)

2 Likes