表达式学习

1.int x = 5>3:2:3.0   取精度高的类型,x的类型是double

2.常量的声明:    const int x = 1;

3.块语句:

int x = 100;
{

Console.WriteLine(x);
int y = 200;
Console.WriteLine(y);

}
Console.WriteLine(y);//访问不到y,y的作用域只是在块语句中

4.快捷键

ctrl + } 可以跳转到{ 的地方 

if +tab+tab 可以直接跳转到条件,输完条件后 按enter,进入块语句中

5.switch用法:

case 10:
if (score==100)
{
goto case 8;
}
else
{
goto default;
}
case 8:
case 9:
Console.WriteLine("A");
break;

6.try catch 可以更精细得捕获异常;finally中一般都写释放资源的语句,或者是程序的log

 7.迭代器 ---所有实现IEnumerable 的都可以被迭代:数组、列表都实现了;

 

posted @ 2024-02-12 16:54  你好呀嗯嗯  阅读(3)  评论(0编辑  收藏  举报