IF Statement multiple conditions, same statement

前端 未结 10 2130
孤城傲影
孤城傲影 2021-02-02 12:23

Hey all, looking to reduce the code on my c# if statements as there are several repeating factors and was wondering if a trimmer solution is possible.

I currently have 2

10条回答
  •  無奈伤痛
    2021-02-02 13:10

    if (checkbox.checked && columnname != a && columnname != b && columnname != c)
        {
          "statement 1"
        }
    else if (columnname != a && columnname != b && columnname != c 
            && columnname != A2)
        {
          "statement 1"
        }
    

    is one way to simplify a little.

提交回复
热议问题