Case Statement Block Level Declaration Space in C#

UPDATE: This question was used as the inspiration for this blog post; see it for further details. http://ericlippert.com/2009/08/13/four-switch-oddities/ Thanks for the interesting question. There are a number of confusions and mis-statements in the various other answers, none of which actually explain why this is illegal. I shall attempt to be definitive. First off, to be … Read more

C++: rationale behind hiding rule

It’s an hairy question, but apparently the idea is that this hiding feature helps avoiding subtle bugs when making changes to a base class (that could otherwise “steal” calls that before would have been handled by the derived class). Still a change in a base class can influence the result of compilation of derived classes … Read more

Why aren’t variables declared in “try” in scope in “catch” or “finally”?

Two things: Generally, Java has just 2 levels of scope: global and function. But, try/catch is an exception (no pun intended). When an exception is thrown and the exception object gets a variable assigned to it, that object variable is only available within the “catch” section and is destroyed as soon as the catch completes. … Read more