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);
}