【发布时间】:2014-03-29 14:09:12
【问题描述】:
我有一个显示特定错误"Cannot convert string'' to Decimal" 的应用程序。我想删除这个错误。我不想显示"Cannot convert string'' to Decimal",但可以显示其他。应该如何编程我的Catch ex As Exception
【问题讨论】:
-
我猜你说的是 C#。对吗?
我有一个显示特定错误"Cannot convert string'' to Decimal" 的应用程序。我想删除这个错误。我不想显示"Cannot convert string'' to Decimal",但可以显示其他。应该如何编程我的Catch ex As Exception
【问题讨论】:
你必须这样写你的代码:
Try
(your code here)
Catch ex As FormatException
(your exception handler)
End Try
这将只捕获 FormatException 类型的异常。正如您在此示例中看到的 http://msdn.microsoft.com/en-us//library/hf9z3s65(v=vs.110).aspx 在 MSDN 中方法的参考中看到的,您始终拥有它抛出的异常类型的信息。
有关异常处理的更多信息,请参阅http://msdn.microsoft.com/en-us//library/fk6t46tz.aspx
【讨论】: