try catch finally

 

 

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

posted @ 2017-03-09 16:37  叶丶梓轩  阅读(93)  评论(0编辑  收藏  举报