您的位置:首页 > 其它

for ..break和try ..catch

2015-06-18 16:07 134 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
/*  for (int i = 1; i <= 100; i++)
{
Console.WriteLine("hello"+i);
if (i == 40)
{
break;//终止离它最近的循环,跳出整个循环
}
}*/
/*while (true)
{ string s=Console.ReadLine();
try//尝试,保护起来,即使程序也能执行出错
{
int a = int.Parse(s);
Console.WriteLine(a);
}
catch (Exception b)//捕获错误,有错误才执行
{
Console.WriteLine(b);
}
finally//不管有没有错最后都执行
{
Console.WriteLine("hello");
}

}*/
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: