Periodically, I wonder about this:The short-circuit OR would always return the same value that the unshort-circuited OR operator would? I expect that the short-circuit OR would always evaluate more quickly. So, was the unshort-circuited OR operator included in the C# language for consistency? What have I missed?
Why is there both a short-circuit OR as well as unshort-circuited variation of that operator in C#?
c#;boolean;logic
Both operands were meant for different things, coming from C which didn't have a boolean type. The short-circuit version || only works with booleans, while the non-short circuit version | works with integral types, performing a bitwise or. It just happened to work as a non-short circuit logical operation for booleans which are represented by a single bit, being 0 or 1.http://en.wikibooks.org/wiki/C_Sharp_Programming/Operators#Logical