What happens with this 2 alternative

  • Thread starter Thread starter Kenneth
  • Start date Start date
K

Kenneth

what happend with the memory in my computer, is alt 1 bad or is alt 2 bad?

alt 1

For Each tblRow As DataRow In Ds.Tables("tbl").Rows

Dim nCoValue As System.Single = CSng(tblRow.Item("nCoValue"))

'Do something with nCoValue

Next



alt 2

Dim nCoValueAs System.Single

For Each tblRow As DataRow In Ds.Tables("tbl").Rows

nCoValue = CSng(tblRow.Item("nCoValue"))

'Do something with nCoValue

Next





//Kenneth
 
Hi Kenneth,

There is a difference
Theoretical but only theoretical there is a change that you keep in the Alt2
example 32 bits some time longer in memory. (Practical it would probably not
because it will be done by the garbadge collector in the same time). (The
last value stays also).

When you had done alt2 like this it had been the same
For Each tblRow As DataRow In Ds.Tables("tbl").Rows
Dim nCoValueAs System.Single
nCoValue = CSng(tblRow.Item("nCoValue"))

'Do something with nCoValue

Next
I hope this helps?

Cor
 
Back
Top