checking whether four boolean variables have equal value, non-obvious?

boolean, c#

Solution

An obvious way would be to pair them and use .Equals() instead of ==

Check this alternative, it could be what you want - Equality comparison between multiple variables

Problem

I have four bool variables, say : ``` bool a=true; bool b=false; bool c=true; bool d=false; ``` then I want to check that those four are equal. However; ``` Console.WriteLine(true == false == true == false); true ``` Why is this happening? I think it is because of evalution order of an equation, which goes from left to right : ``` ((true == false) == true) == false (false == true) == false false == false true ``` then What is a proper way to check whether all N>2 boolean variables are equal?

Original source

Related problems