c# - eliminate return function -


How many return statements can I remove in a statement. Example: If the clause, if the clause is true, the result is 0 Will return or will return 1, and if there is a second, if the clause will be. It also has a return value.

  if (IGC == true) {if (val1.ToUpper) == val2 is I.. (()) {Return 0; } And {return1; }} Else {if (val1 == val2) {return 0; } And {return1; }}  

My guess is on the logic ...

int radial; If (condition) {// statements retVal = 0; } Else {// statement if (other condition) {retVal = 1; } And {retVal = 2; }} Return Rate Vals;

and with your now-post updates:

  int retVal; If (IGC) is rated = (well 1.ToUpper () == val2.ToUpper ())? 0: 1; And retVal = (val1 == val2)? 0: 1; Return rate;  

I avoid nesting torture operators or check more than one condition with them, because this code really makes it very vague, it is not that if the code is more clear If the code goes on, the code is entirely about readability.

I try to weight the code length and visual complexity against the expression, and if / ternary combination seems to be a good middle ground for me.


Comments