Saturday, 24 June 2017
c# - Performance difference in loop
Answer
Answer
Possible Duplicate:
Difference between declaring variables before or in loop?
Is there any (or any notable) performance difference when I write for example something like this (consider loading tens or hundreds of thousands rows from DB into the collection of Foo objects):
...
Foo myFoo;
while(reader.Read())
{
myFoo = new Foo();
myFoo.SomeProperty = reader.GetValue(0);
...
fooCollection.Add(myFoo);
}
or this
...
while(reader.Read())
{
Foo myFoo = new Foo();
myFoo.SomeProperty = reader.GetValue(0);
...
fooCollection.Add(myFoo);
}
Subscribe to:
Post Comments (Atom)
casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV
In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...
-
Parse error: syntax error, unexpected '(', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' ...
-
The whole error output being: LNK2019 unresolved external symbol wWinMain referenced in function "int __cdecl __scrt_common_main_seh(vo...
-
I recently used canvas to conert images to webp, using : const dataUrl = canvas.toDataURL('image/webp'); But this takes a lots of ti...
No comments:
Post a Comment