difference between these code
-
Hi, I'm new in vb.net What the difference of these codes
for u = 0 to datatable.rows.count - 1
' process code
nextfor each rows in datatable.rows
' process code
nextassuming process code are to parsing data datatable.rows either to search or to print or to calculate. which one is faster ? can someone give me some enlighment ? sorry for bad english.
-
Hi, I'm new in vb.net What the difference of these codes
for u = 0 to datatable.rows.count - 1
' process code
nextfor each rows in datatable.rows
' process code
nextassuming process code are to parsing data datatable.rows either to search or to print or to calculate. which one is faster ? can someone give me some enlighment ? sorry for bad english.
One loop is an indexer and the other is an enumator. Indexers can modify the collection while you're iterating over it while enumators cannot. Indexers are a little faster than enumerators, but also require you to know more about the size and types the array holds.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Hi, I'm new in vb.net What the difference of these codes
for u = 0 to datatable.rows.count - 1
' process code
nextfor each rows in datatable.rows
' process code
nextassuming process code are to parsing data datatable.rows either to search or to print or to calculate. which one is faster ? can someone give me some enlighment ? sorry for bad english.
Just to add to Dave's comment - The for-loop is faster than the foreach-loop if the array must only be accessed once per iteration. (More Details with Benchmark Test[^]).
If you can dream it, You can do it. Explore My School
-
One loop is an indexer and the other is an enumator. Indexers can modify the collection while you're iterating over it while enumators cannot. Indexers are a little faster than enumerators, but also require you to know more about the size and types the array holds.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Just to add to Dave's comment - The for-loop is faster than the foreach-loop if the array must only be accessed once per iteration. (More Details with Benchmark Test[^]).
If you can dream it, You can do it. Explore My School
-
My pleasure yuifox... Happy coding ;)
If you can dream it, You can do it. Explore My School - Schools In India
-
Hi, I'm new in vb.net What the difference of these codes
for u = 0 to datatable.rows.count - 1
' process code
nextfor each rows in datatable.rows
' process code
nextassuming process code are to parsing data datatable.rows either to search or to print or to calculate. which one is faster ? can someone give me some enlighment ? sorry for bad english.
El segundo código es mas eficiente y rapido.
_______________________ Edward J. Ocando. | Desarrollador | SoyDesarrollador.net Telefono. +58 (416) 164.34.88 | Edward.Ocando@soydesarrollador.net