Possible Duplicate:
Why can’t a duplicate variable name be declared in a nested local scope?
I noticed that the following code didn't compile. Quick fix was to recall the outer variable thing
to something else but then I started to think and realized that the internal scope should end within the foreach
loop. I sure can't use the internal variable outside it.
Shouldn't I be able to reuse the name thing
outside the loop? Why?
String aggregate = String.Empty;
foreach (Thing thing in things)
aggregate += thing.Value;
Thing thing = new Thing();