⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch2_18.cs

📁 《c#技术内幕代码》
💻 CS
字号:
using System;

class CH2_18
{
   public static void CallExceptionFunction()
   {
      throw new Exception("This is an exception");
   }
   
   public static void Main()
   {

	try 
	{
	  // Call a function that throws an exception
	  try 
	  {
	    CallExceptionFunction();
	    Console.WriteLine("This should never be printed");
	    throw new Exception("Bad Error Exception");
	  }
	  catch( Exception e) 
	  {
	    Console.WriteLine("Catching the BadError Exception");
  	    throw new Exception("Rethrowing", e);
	  }
          finally 
          {
              Console.WriteLine("Finally Statement #1");
          }
        }
        catch ( Exception e) 
	{
	   Console.WriteLine("Catching Exception #2 {0}", e );
	}
        finally 
	{
	   Console.WriteLine("We are at the last outside nested block");
	}
	try
	{
	   Console.WriteLine("No error will occur here");
	}
	catch ( Exception e )
	{
	   Console.WriteLine("Caught an exception in a BAD place {0}", e );
	}
	finally
	{
	   Console.WriteLine("This is the last finally block");
	}
	
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -