📄 ex-03-15
字号:
//Example 03-15: Using continue and break
using System;
public class Tester
{
public static int Main()
{
string signal = "0"; // initialize to neutral
while (signal != "X") // X indicates stop
{
Console.Write("Enter a signal: ");
signal = Console.ReadLine();
// do some work here, no matter what signal you
// receive
Console.WriteLine("Received: {0}", signal);
if (signal == "A")
{
// faulty - abort signal processing
// Log the problem and abort.
Console.WriteLine("Fault! Abort\n");
break;
}
if (signal == "0")
{
// normal traffic condition
// log and continue on
Console.WriteLine("All is well.\n");
continue;
}
// Problem. Take action and then log the problem
// and then continue on
Console.WriteLine("{0} -- raise alarm!\n",
signal);
}
return 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -