Juval Lowy's C# Coding Standards Questions

后端 未结 8 2090
无人共我
无人共我 2021-01-30 18:07

I enjoy and highly recommend Juval Lowy\'s - C# Coding Standard. Juval explicitly avoids rationale for each directive in order to keep the standard tight (see the preface). Howe

8条回答
  •  既然无缘
    2021-01-30 18:37

    2.29 Avoid using the ternary conditional operator I have no problems with "simple" uses of the ternary operator but have recommended against using it in a nested fashion:

    // This is fine
    x := (conditionA) ? true_resultA : false_resultA;
    
    // This would probably be clearer using if-then-elseif
    x := (conditionA) ? 
           ((conditionA1) ? true_resultA1 : (condition2) ? true_result2 : false_result2) :
           ((conditionA2) ? true_resultA2 : false_resultA2);
    

提交回复
热议问题