zhangsk 发表于 2013-2-5 01:19:24

switch

<div class="postText">在c++中
switch(choice)
{
   case 1:
   case 2:
   case 3:
   default:
}
如果这样的执行代码就会把所有的case走到(java中也是如此),所以不要忘记在case中加入break;
switch(choice)
{
   case 1: A
    break;
   case 2: B
    break;
   case 3: C
    break;
   default:       break;



delphi中就不用了。
case I of
  1..5: Caption := 'Low';
  6..9: Caption := 'High';
  0, 10..99: Caption := 'Out of range';
else
  Caption := '';
end;
页: [1]
查看完整版本: switch