Continue activity in DataTable

Hi,

I use a DataTable to process each line on CSV.
I have to break for each line in order to make other things (Get value, write …)
After i made other things, i want to go to next row in DataTable but i can’t. It still the data of first row …

Any idea ?

test.zip (3.4 KB)

Keep a counter (before for each and initial value 0) and Increment for every Iteration.

Inside foreach use this dt.Rows.Cast(Of DataRow)().Skip(Count)
get values
Increment counter +1
break foreach

do other things

go back to foreach

Foreach_Skip.xaml (15.5 KB)

2 Likes

Hello,

It’s work properly.

Thanks :slight_smile:

Thanks for the idea. Even i didn’t know earlier that this can be done.

Its more like a for loop

1 Like

If it’s always just taking one row values, why ForEach at all?
DataRow currentRow = dt.Rows(counter)
will get the row needed, without needing to iterate the collection (although it’s a neat trick with Skip).

Agreed.Probably I was thinking to accomplish using foreach and was intrigued with skip and take concepts which gives flexibility to pick desired rows.

Thanks,
Vinay

@andrzej.kniola, it’s not just to keep one row values but several.