Tag Info

New answers tagged

0

In the first example, I would assume that the variable has been declared in advance to avoid garbage collection issues, except there are only 10 iterations, and if you don't have enough ram to handle that, then you have a bigger issue on your hands than memory management. This might be useful to declare a variable only once, if that object takes up a lot of ...


5

In terms of memory allocation and performance, the first snippet contains a superfluous assignment of the empty string to q before entering the loop. From a performance point of view this should not be of any concern whatsoever, but from a best software engineering practices point of view, the second snippet is definitely preferable, since the variable is ...


-1

They are the same in terms of performance. In VB.NET, a variable that is declared inside a loop keeps its value for the next itaration. I would prefer the frist example as it is easier to read and probably has the intended behavior. Here's the output of the two: > Some text 0 > Some text 1 > Some text 2 > Some text 3 > Some text 4 ...



Top 50 recent answers are included