异常

            for (int i = 0; i < 20; i++)
            {
                try
                {
                    if (i == 10)
                        throw new Exception("出错了");
                    Console.WriteLine(i);
                }
                catch (Exception)
                {
                    Console.WriteLine("异常进行了处理。");
                }
            try
            {
                for (int i = 0; i < 20; i++)
                {
                    if (i == 10)
                        throw new Exception("出错了");
                    Console.WriteLine(i);


                }
            }
            catch (Exception)
            {
                Console.WriteLine("异常进行了处理。");
                //throw;
            }
static void Main(string[] args)
        {
            try
            {
                t01();
                Console.WriteLine("continue?");
            }
            catch (Exception e)
            {
                Console.WriteLine("Main捕获到了异常");
                Console.WriteLine("main:" + e.Message);
                //throw;
            }

            Console.Read();


        }

 public static void t01 (){
            Console.WriteLine("this is in t01");
            try
            {
                t02();
            }
            catch (Exception e)
            {
                Console.WriteLine("t01捕获到了异常");
                throw e;
            }
            
            //throw new Exception("t01抛出异常");
        }

        public static void t02()
        {
            Console.WriteLine("this is in t02");
            throw new Exception("t02抛出异常");
        }
原文地址:https://www.cnblogs.com/mrxiaohe/p/6530184.html