C#允许您在case:
语句之间的switch()
语句中省略大括号吗?C#切换语句带/不带大括号....有什么区别?
像JavaScript程序员经常做的那样,忽略它们的效果如何?
实施例:
switch(x)
{
case OneWay:
{ // <---- Omit this entire line
int y = 123;
FindYou(ref y);
break;
} // <---- Omit this entire line
case TheOther:
{ // <---- Omit this entire line
double y = 456.7; // legal!
GetchaGetcha(ref y);
break;
} // <---- Omit this entire line
}
从Java世界http://stackoverflow.com/questions/633497/java-switch-cases-with-or-without-braces – nawfal 2013-05-05 09:46:06