Microsoft has left some room for ReSharper.  :P

Without braces:    error - 'Invalid embedded statement'
With braces:    warning - 'Local variable 'foo' is never used'

Cheers,
Chris

From: [email protected] [mailto:[email protected]] 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 
<[email protected]<mailto:[email protected]>> 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

Reply via email to