Methods of simplifying ugly nested if-else trees in C#

前端 未结 11 800
野性不改
野性不改 2021-02-02 04:23

Sometimes I\'m writing ugly if-else statements in C# 3.5; I\'m aware of some different approaches to simplifying that with table-driven development, class hierarchy, anonimous m

11条回答
  •  Happy的楠姐
    2021-02-02 04:39

    One thing I find myself doing at times is inverting the condition followed by return; several such tests in a row can help reduce nesting of if and else.

提交回复
热议问题