例子:
08.try
09.{
10.程序代码块;
11.}
12.catch(Exception e)
13.{
14.异常处理代码块;
15.}
16.finally
17.{
18.无论是否发生异常,均要执行的代码块;
19.}
第一种方法:
string sr=Console.ReadLine();
int n;
if(int.TryParse(sr,out n))
{
Console.Write(n)
}
else
{
n=0;
}
第二种方法:
try
{
n=convert.ToInt32(sr);
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载