CSDN说明:
条件“或”运算符 (||) 执行 bool 操作数的逻辑“或”运算,但仅在必要时才计算第二个操作数。
件“与”运算符 (&&) 执行其 bool 操作数的逻辑“与”运算,但仅在必要时才计算第二个操作数
同时我们还要了解到 || 和 && 都是左结合性的逻辑运算符,所以看下面的例子
class Program
{
static void Main(string[] args)
{
int a = 9;
int b = 10;
int c = 11;
int d = 12;
if (d>b || c > b && a>b)
{
Console.WriteLine("true");
}
Console.ReadKey();
}
}
所以在判断到d>b为true时,后面的部分c > b && a>b就不会再运算,进入条件语句里面
原文:http://www.cnblogs.com/liuww/p/4658176.html