1,语句:
语句是构造所有C#程序的过程块,通常以分号结束。有大括号括起来的一系列语句构成代码块,方法是代码块的一个示例,有:条件语句(if....else语句,switch语句),循环语句(for语句,foreach语句,while语句,do....while语句),跳转语句(break,语句continue语句,return,goto语句)
2,异常处理语句
try........catch,try.........catch........finally,try.............finally异常处理语句中必须有try语句和catch或finally中的一个
3,checked,Unchecked语句
static short x = 32767;
static short y = 2;
static int CheckedMethod()
{
short z = unchecked((short)(x + y));
return z;
}
static void Main()
{
Console.WriteLine(
“值为:{0}", CheckedMethod());
}
输出结果为:-32767
当把unchecked变为chenck时会出现异常,因为short类型的上限为32767,当再加1时会变成-32768
转载于:https://blog.51cto.com/lixinya/353079