Actually, visual studio does this: A local variable named 'foo' cannot be declared in this scope because it would give a different meaning to 'foo', which is already used in a 'parent or current' scope to denote something else
David "If we can hit that bullseye, the rest of the dominoes will fall like a house of cards... checkmate!" -Zapp Brannigan, Futurama On 5 June 2013 00:21, mike smith <meski...@gmail.com> wrote: > On Tue, Jun 4, 2013 at 4:44 PM, Fredericks, Chris <chris.frederi...@hp.com > > wrote: > >> Microsoft has left some room for ReSharper. :P**** >> >> ** ** >> >> Without braces: error - ‘Invalid embedded statement’**** >> >> With braces: warning - ‘Local variable ‘foo’ is never used’**** >> >> ** >> > > And then there's variable hiding, which some analysis tools pick up. > > "outer foo is hidden by inner foo" > > >> ** >> >> Cheers,**** >> >> Chris**** >> >> ** ** >> >> *From:* ozdotnet-boun...@ozdotnet.com [mailto: >> ozdotnet-boun...@ozdotnet.com] *On Behalf Of *David Burstin >> *Sent:* Tuesday, 4 June 2013 4:06 PM >> *To:* ozDotNet >> *Subject:* Re: If-else vs switch - declaring inner variables (a >> philosophical question)**** >> >> ** ** >> >> ** ** >> >> On 4 June 2013 15:43, Piers Williams <piers.willi...@gmail.com> wrote:*** >> * >> >> You've basically asked about C#'s scoping rules. Eric Lippert has >> answered this question a few times, here he is talking about it on >> StackOverflow:**** >> >> http://stackoverflow.com/a/2050864**** >> >> >> Thanks for the link - some interesting reading there.**** >> >> ** ** >> >> Do you have any info for the later question - "Why can't a useless >> variable be declared after an if without braces, but is ok if we wrap that >> single line in a pair of curlies?". I haven't been able to find anything. >> **** >> >> ** ** >> >> Cheers**** >> >> DB**** >> > > > > -- > Meski > > http://courteous.ly/aAOZcv > > "Going to Starbucks for coffee is like going to prison for sex. Sure, > you'll get it, but it's going to be rough" - Adam Hills >