首页 > Windows开发 > 详细

C# try catch finally

时间:2020-06-18 12:39:34      阅读:44      评论:0      收藏:0      [点我收藏+]

情形1: 

try
{
    int i = 0;
    i = int.Parse("t");
    Console.WriteLine("Try");
}
catch (Exception e)
{
    Console.WriteLine("Catch");
}
finally
{
    Console.WriteLine("Finally");
}

Console.WriteLine("End");

技术分享图片

情形2:  

try
{
    int i = 0;
    i = int.Parse("t");
Console.WriteLine("Try");   }
finally { Console.WriteLine("Finally"); } Console.WriteLine("End");

技术分享图片

 情形3:  

try
{
    int i = 0;
    i = int.Parse("t");
Console.WriteLine("Try"); }
catch (Exception e) { Console.WriteLine("Catch"); } Console.WriteLine("End");

技术分享图片

  情形4:  

try
{
    int i = 0;
    i = int.Parse("12");
Console.WriteLine("Try"); }
catch (Exception e) { Console.WriteLine("Catch"); } finally { Console.WriteLine("Finally"); } Console.WriteLine("End");

 技术分享图片

 情形5:

int i = 0;
i = int.Parse("t");

Console.WriteLine("End");

技术分享图片

 

C# try catch finally

原文:https://www.cnblogs.com/qinruijie/p/13156895.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!