我无法理解这个移位运算符(c#reference):
class MainClass1
{
static void Main()
{
int i = 1;
long lg = 1;
Console.WriteLine("0x{0:x}", i << 1);
Console.WriteLine("0x{0:x}", i << 33);
Console.WriteLine("0x{0:x}", lg << 33);
}
}
/*
Output:
0x2
0x2
0x200000000
*/
class MainClass2
{
static void Main()
{
int a = 1000;
a <<= 4;
Console.WriteLine(a);
}
}
/*
Output:
16000
*/
Run Code Online (Sandbox Code Playgroud) 请演示三元运算符如何使用常规if/else块.例:
Boolean isValueBig = value > 100 ? true : false;
Run Code Online (Sandbox Code Playgroud)
完全重复: 如何使用三元运算符?