Simple Question

R

randy

This maybe a silly question, but I like efficiency in my code so I'll ask.
Will the following 2 For/Each statements do the same thing?


Dim datRow as DataRow

For each datRow in DataTable.Select("State = HI")

Next

I would normally add an extra step and hold the returned rows first...

Dim datRows() as DataRow
Dim datRow as DataRow

datRows = DataTable.Select("State = HI")

For each datRow in datRows

Next

Cheers,
-Randy
 
C

Cor Ligthert

Hi Randy,

For this you can use IlDasm

It is normaly in this folder
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\ildasm.exe

With that you can exactly see how your code is build.

It is not impossible that the second you use is more efficient than the
first when the select is every time evaluated, but I don't know how it is
optimized. However with that Ildasm tool you can see that yourself.

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top