if后面不加大括号的效果

1.不加{}

if (status == null)
       x=1;y=2;z=3;

编译后

if (status == null)
      { x=1};y=2;z=3; 所以当status != null,y=2;z=3;仍执行。

1.加{}

if (status == null)
      { x=1;y=2;z=3;}

status != null时,都不执行。

猜你喜欢

转载自blog.csdn.net/just_lover/article/details/81324370