Which is generally fastest when reading/comparing row info from a DataTable?
'assume dt as datatable' 'method 1' dim i as int32 for i = 0 to dt.rows.count - 1 .... next 'method 2' dim row as datarow for each row in dt.rows .... next
And if there’s a difference, in what circumstances does it pay to use one over the other?
Thanks in advance for any guidance!
The compiler expands For Each to a short while loop.
So you pay a small amount of overhead. But for clarities sake, I’d still stick with For Each if you’re only working on one row, and you aren’t modifying the data set.