int 的预定义隐式数值转换的类型。
备注
也就是实际的 shift 计数为 0 到 31 位。
也就是实际的 shift 计数为 0 到 63 位。
移位操作从不导致溢出。
重载二元运算符时,也会隐式重载相应的赋值运算符(如果有)。
示例
1 class MainClass11 2 { 3 static void Main() 4 { 5 int i = 1; 6 long lg = 1; 7 // Shift i one bit to the left. The result is 2. 8 Console.WriteLine("0x{0:x}", i << 1); 9 // In binary, 33 is 100001. Because the value of the five low-order 10 // bits is 1, the result of the shift is again 2. 11 Console.WriteLine("0x{0:x}", i << 33); 12 // Because the type of lg is long, the shift is the value of the six 13 // low-order bits. In this example, the shift is 33, and the value of 14 // lg is shifted 33 bits to the left. 15 // In binary: 10 0000 0000 0000 0000 0000 0000 0000 0000 16 // In hexadecimal: 2 0 0 0 0 0 0 0 0 17 Console.WriteLine("0x{0:x}", lg << 33); 18 } 19 } 20 /* 21 Output: 22 0x2 23 0x2 24 0x200000000 25 */