跳转至

控制语句⚓︎

一、判断⚓︎

if ()
{
    // todo 
} 
else if ()
{
    // todo 
}
else
{
    // todo 
}

二、选择⚓︎

switch(expression){
    case constant:
       statement(s);
       break; 
    case constant:
       statement(s);
       break; 
    default : // 可选的
       statement(s);
       break; 
}

三、循环⚓︎

while(condition){
    //todo
}
do
{
    // todo
}while(condition);
for (init; condition; increment)
{
    // todo
}
foreach (type element in array)  
{  
    // todo
}

四、跳转⚓︎

break;

continue;

goto;

return;

五、输入输出⚓︎

// 输入
Console.Read();// 返回用户从控制台上输入数据的首字符的ASCLL码
Console.ReadLine(); // 最常用的输入语句,把用户输入的一行信息用string类型的字符串返回
Console.ReadKey(); // 当我们需要让程序在某个地方暂停,然后观察程序运行效果时,可以使用

// 输出
Console.Write("你好!"); // 输出以后不会自动换行
Console.WriteLine("你好!"); // 输出以后自动换行