checked、is、as、sizeof、typeof运算符、空合并运算符

 //--------------------------------checked防止溢出
            byte b = 255;
            checked
            {
                b++;
            }
            Console.WriteLine(b.ToString());//byte类型只包含0~255,加上checked因此会抛出异常ide

            //is运算符,检查对象是否与特定的类型兼容
            int i = 0;
            Console.WriteLine(i is object);//True对象

            //--------------------------------as运算符,显示转换特定的类型
            object o = "123";
            string s = o as string;
            Console.WriteLine(s);string

            //--------------------------------sizeof运算符,能够肯定栈中值类型的长度
            Console.WriteLine(sizeof(int));//输出4it


            //--------------------------------typeof运算符,返回一个特定类型的System.Type对象
            Console.WriteLine(typeof(string));//输出System.String
           
            Console.ReadKey();class

             

 

            //--------------------------------可空运算符与空合并运算符object

            int? i = null;//int?可空运算符
            int? a = i ?? 10;//空合并运算符 (若是??前面是空则等于第二个值)
            Console.WriteLine(a);//输出10
            Console.ReadKey();异常