案例如下:您有一个名为FullScreenEnabled的布尔属性.输入一些方法,如果FullScreenEnabled为true,则执行此方法中的代码.您在日常编程中使用以下两种方法中的哪一种:
private bool FullScreenEnabled { get; set; } // Check if FullScreenEnabled is false and return; private void Case1() { if (FullScreenEnabled == false) { return; } // code to be executed goes here! } // Surround the code by an if statement. private void Case2() { if (FullScreenEnabled) { // code to be executed goes here! } }
Oskar.. 11
private void MyMethod(bool arg){ if(arg) return; //do stuff };
(投票)
private void MyMethod(bool arg){ if(arg) return; //do stuff };
(投票)