小编Sar*_*a S的帖子

了解班次操作员

我无法理解这个移位运算符(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)

c#

19
推荐指数
2
解决办法
3万
查看次数

三元运算符如何工作?

请演示三元运算符如何使用常规if/else块.例:

Boolean isValueBig = value > 100 ? true : false;
Run Code Online (Sandbox Code Playgroud)

完全重复: 如何使用三元运算符?

c c# java ternary-operator

8
推荐指数
6
解决办法
1万
查看次数

标签 统计

c# ×2

c ×1

java ×1

ternary-operator ×1