/异常语句try,catch.
//try//保护执行里面的代码段,若其中一句错误,直接跳转到catch,不会管下面的内容
//{
// Console.WriteLine("请输入一个整数");
// int a = int.Parse(Console.ReadLine());
// Console.WriteLine("hello");
// break;
//}
//catch//
//{
// Console.WriteLine("您的输入有误");
//}
//Console.ReadLine();
//for与if else的使用
Console.WriteLine("你爱不爱我");
for (int i = 1; i <= 3; i++)
{
string a = Console.ReadLine();
if (a == "爱")
{
Console.WriteLine("我也爱你");
System.Threading.Thread.Sleep(2000);//单位:毫秒
Console.WriteLine("从此王子和公主过上了没羞没臊的生活");
break;
}
else
{
if (i == 1)
{
Console.WriteLine("你爱不爱我");
}
if(i == 2)
{
Console.WriteLine("我问你,你到底爱不爱我");
}
if (i == 3)
{
Console.WriteLine("滚");
}
}
}
Console.ReadLine();
//请输入年月日,判断格式是不是正确
//for (; ; )
//{
// Console.WriteLine("请输入年份:");
// int y = int.Parse(Console.ReadLine());
// if (y >= 0 && y <= 9999)
// {
// for (; ; )
// {
// Console.WriteLine("请输入一个月份:");
// int m = int.Parse(Console.ReadLine());
// if (m > 0 && m <= 12)
// {
// for (; ; )
// {
// Console.WriteLine("请输入一个日期:");
// int d = int.Parse(Console.ReadLine());
// if (d > 0 && d <= 31)
// {
// Console.WriteLine(y+ "年" + m + "月" + d+ "日" );
// break;
// }
// else
// {
// Console.WriteLine("您输入的日期有误");
// }
// }
// break;
// }
// else
// {
// Console.WriteLine("您输入的月份有误");
// }
// }
// break;
// }
// else
// {
// Console.WriteLine("您的输入年份有误");
// }
//}
// Console.ReadLine();

浙公网安备 33010602011771号