vb.net – 异常后继续代码

前端之家收集整理的这篇文章主要介绍了vb.net – 异常后继续代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想知道是否有办法让程序在抛出异常后继续.例如:
Try
  line 1
  line 2
  line 3
  line 4 ( here the exception is thrown and jumps to the catch)
  line 5  <-- i would like the program to continue its execution loging the error
  line 6  

Catch ex as Exception
   log(ex.tostring)
End Try

谢谢.

如果你正在做一些你知道如何恢复或者不重要的事情,那么你应该在try / catch中用特定的catch来包装那一行.
例如
Try 
  line 1
  line 2
  line 3
  Try
     line 4 ( here the exception is throw and jumps to the catch)
  Catch iox as IOException ' or whatever type is being thrown
     'log it
  End Try
  line 5  <-- i would like the program to continue its execution after loggin the error
  line 6  

Catch ex as Exception
   log(ex.tostring)
End Try
原文链接:https://www.f2er.com/vb/255337.html

猜你在找的VB相关文章