question on technique in .net

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: C Williams (nospam_at_thank.you)
Date: 02/03/05


Date: Thu, 03 Feb 2005 11:22:56 -0500

I find myself needing to loop through various collections in .NET a lot.
  I am wondering if there is a generally accepted method for doing so.
I see three main ways (I'll use rows in a DataTable, which I am doing a
lot of work with)

1) For each curRow in curTable.Rows
2) For i = 0 to curTable.Rows.Count -1
          currow = curtable.rows(i)
3) use curTable.Rows.GetEnumerator

Option 1 yields the shortest code, but which runs the fastest? I
suspect they are very similar, but I also suspect that someone out there
actually *knows*!

Thanks for any insights you have!

-Casey



Relevant Pages

  • Re: post-hibernation wakeup requires mouse/keypress
    ... Is this a console app (I suspect so since you are using printf statements)? ... Are you getting any other message in that loop after the ...
    (microsoft.public.windowsxp.embedded)
  • Re: [patch 17/20] non-reclaimable mlocked pages
    ... Peter Zijlstra wrote: ... anon and file) out onto the non-reclaim list, ... I suspect we won't be needing that code. ...
    (Linux-Kernel)
  • Re: question on technique in .net
    ... Using an enumerator is a nice clean way to do it, unfortunately, you cannot ... change anything in the collection which might upset the loop. ... I suspect that the differences will be quite small. ... >I find myself needing to loop through various collections in .NET a lot. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: ASP Include Problems
    ... Just so I don't come across as a complete moron, I've already apologised to David for my harsh post having started and email discussion. ... After feeling guilty for a few mins 'we' may have found a suspect loop that appears to run indefinitely in certain circumstances thus hanging ASP. ... Got an include file causing a timeout on the server when it's called on... ...
    (microsoft.public.inetserver.asp.general)
  • Re: command prompt opens without RUN, how to avoid?
    ... advice me how to avoid this.... ... I suspect that cscript.exe is set as your default script host. ... And that loop is just an extract :-) ...
    (microsoft.public.scripting.wsh)