用
 try{} catch()
 { } finally{} 来处理你程序中的各种异常

解决方案 »

  1.   


    一起使用 catch 和 finally 的通常用法是在 try 块中获取并使用资源,在 catch 块中处理异常情况,在 finally 块中释放资源。
    using System;
    public class EHClass 
    {
       public static void Main () 
       {
          try 
          {
             Console.WriteLine("Executing the try statement.");
             throw new NullReferenceException();
          }      catch(NullReferenceException e) 
          {
             Console.WriteLine("{0} Caught exception #1.", e); 
          }      catch 
          {
             Console.WriteLine("Caught exception #2.");
             
          }      finally 
          {
             Console.WriteLine("Executing finally block.");
          }
       }
    }
      

  2.   

    在操作资源/数据时用
     try
    {}
     catch()
     { }
      

  3.   

    try
    {
    }
    catch
    {
    }
    finally
    {
    }
      

  4.   

    windows的报错对话框也能在CATCH块中捕捉到吗?
      

  5.   

    try
    {}
    catch
    {}
    finally
    {}
    只能在自己写的程序当中判断是否有异常产生
    而如果我在用A程序调用B程序,那么如果想知道B中是否弹出了一个报错的对话框,应该怎么去判断呢?
      

  6.   

    Postmessage(FindWindow(nil,"err"),WM_CLOSE,0,0);
      

  7.   

    使用
    try
    {}
    catch
    {}
    finally
    {}足以,使用抓窗口的方式又需要开启一个进程。