| 之间有什么区别?和||或者 C# 中的运算符?

| 之间有什么区别?和||或者 C# 中的运算符?

class Program {
static void Main(string[] args){
int a = 4;
int b = 3;
int c = 0;
c = a | b;
Console.WriteLine("Line 1 - Value of c is {0}", c);
Console.ReadLine();
}
}

输出

Value of c is 7
Here the values are converted to binary
4−−100
3−−011
Output 7 −−111

登录后复制

Example 2

的翻译为:

示例2

static void Main(string[] args){
int a = 4;
int b = 3;
int c = 7;
if (a > b || b > c){
System.Console.WriteLine("a is largest");
} else {
System.Console.WriteLine("a is not largest");
}
Console.ReadLine();
}

登录后复制

输出

a is largest

登录后复制

在上面的示例中,其中一个条件返回 true,因此它永远不会检查下一个条件。

以上就是| 之间有什么区别?和||或者 C# 中的运算符?的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!