Lars,
In addition to the other comments.
Does it really matter?
I find its better to code for "correctness" (OO) and "readability" first,
then code for performance only when a routine has proven to have performance
problems via profiling.
IMHO: For Each is much more readable then the IEnumerator loop, plus For
Each is more "correct" in that the For Each will call IEnumerator.Dispose
for me if needed...
Also as David stated, the For Each is implemented in terms of IEnumerator,
there is not going to be any real difference in speed.
In addition to David's sample of using DateTime.Now to time code, I normally
use QueryPerformanceCounter to time code.
http://support.microsoft.com/default...b;en-us;306978
Hope this helps
Jay
"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:ua*************@tk2msftngp13.phx.gbl...
I have a Dataset with one table in it.
If I need to loop thru that table I know of two ways that I would choose..
1. Do a "For Each DataRow in Datatable"
2. You create an IEnumerator fron the Table.Rows object. And loop thru
that one (a bit more code needed).
Questions:
1. Which one would be fastest and Why?
2.In general... how do you actually measure a thing like that, are there a
very precise way of measuring or any guidlines that you can use in general
to figure out what techniques you should choose in different situations?
Best Regards/
Lars Netzel