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

后端 未结 8 1587
梦毁少年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:49

    If EXACTLY ONE should be true then it is:

    var male = bool.Parse(staff.getValue("Male"));
    var female = bool.Parse(staff.getValue("Female"));
    
    if (male ^ female)    
    {
       //is true
    }
    

提交回复
热议问题