Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

| Operator

Binary | operators are predefined for the integral types and bool. For integral types, | computes the bitwise OR of its operands. For bool operands, | computes the logical OR of its operands; that is, the result is false if and only if both its operands are false.

expr1 | expr2

Where:

expr1
An expression.
expr2
An expression.

Remarks

User-defined types can overload the | operator (see operator).

Example

// cs_operator_OR.cs
using System;
class Test 
{
   public static void Main() 
   {
      Console.WriteLine(true | false);  // logical or
      Console.WriteLine(false | false); // logical or
      Console.WriteLine("0x{0:x}", 0xf8 | 0x3f);   // bitwise or
   }
}

Output

True
False
0xff

See Also

C# Operators | 7.10 Logical operators

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft