微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

| 之间有什么区别?和||或者 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# 中的运算符?的详细内容,更多请关注编程之家其它相关文章

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐