“或”赋值运算符。
备注
使用 |= 赋值运算符的表达式,例如
复制代码 | |
|---|---|
x |= y | |
等效于
复制代码 | |
|---|---|
x = x | y | |
不同的是 x 只计算一次。| 运算符对整型操作数执行按位逻辑“或”运算,对布尔操作数执行逻辑“或”运算。
示例
复制代码 | |
|---|---|
// cs_operator_or_assignment.cs
using System;
class MainClass
{
static void Main()
{
int a = 0x0c;
a |= 0x06;
Console.WriteLine("0x{0:x8}", a);
bool b = true;
b |= false;
Console.WriteLine(b);
}
} | |
输出
0x0000000e True | |
请参见