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