【发布时间】:2013-01-31 02:59:24
【问题描述】:
有时人们想对两种不同类型的异常做同样的事情。我搜索了,但没有找到任何适用于 VB.NET 的内容。
简单示例:
Try
'...
Catch ex As Net.WebException
'Do something
Catch ex As Net.CookieException
'Do the same
Catch ex As Exception
'...
End Try
我想知道是否有一种方法可以一次捕获两个异常而无需重复代码。
【问题讨论】:
-
与 C# 中的方法相同,只是语法会有所不同。 stackoverflow.com/questions/136035/…
-
嘿等等...第二个答案正是您想要的。 stackoverflow.com/a/136114/1386111
-
@AlvinWong 哇,是的,谢谢。
标签: vb.net exception try-catch