码迷,mamicode.com
首页 > 其他好文 > 详细

try catch finally

时间:2017-03-09 17:21:12      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:cep   stat   ace   []   gen   cat   抛出异常   linq   ram   

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace delegateDiff
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 1;
            string b = "abc";
            string c = "";
            try
            {
                a = Convert.ToInt32(b);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                c = "123";
                Console.Write(c);
                Console.ReadKey();
            }
            
        }
    }
}

 输出结果是:会抛出异常,但是还会执行finally

try catch finally

标签:cep   stat   ace   []   gen   cat   抛出异常   linq   ram   

原文地址:http://www.cnblogs.com/May-day/p/6431205.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!