一般是这样的,如果你后面的语句非要执行那么使用finally区块即可.class myApp
{
   public static void Main()
   {
      ResourceWrapper r1 = new ResourceWrapper();
      try
      {
         // Do something with the object.
         r1.DoSomething();
      }
      finally
      {
         // Check for a null resource.
         if (r1 != null)
         // Call the object's Dispose method.
         r1.Dispose();
      }
   }
}