C# How do I check if one of two values is TRUE?

后端 未结 8 1512
梦毁少年i
梦毁少年i 2021-01-12 13:24

Should be a simple question for the C# experts here.

I basically want to check if one value or another is TRUE, a wild stab at the code is below:

if          


        
8条回答
  •  一生所求
    2021-01-12 13:45

    The conditional OR operator || is what you need

    if ((Boolean.Parse(staff.getValue("Male")) || Boolean.Parse(staff.getValue("Female")))
    {
       //is true
    }
    

    If the first condition is TRUE, then the second condition isn't checked since the outcome is obviously going to return TRUE.

提交回复
热议问题