本文整理汇总了VB.NET中System.OverflowException类的典型用法代码示例。如果您正苦于以下问题:VB.NET OverflowException类的具体用法?VB.NET OverflowException怎么用?VB.NET OverflowException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OverflowException类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1:
Dim value As Integer = 780000000
Try
' Square the original value.
Dim square As Integer = value * value
Console.WriteLine("{0} ^ 2 = {1}", value, square)
Catch e As OverflowException
Dim square As Double = Math.Pow(value, 2)
Console.WriteLine("Exception: {0} > {1:E}.", _
square, Int32.MaxValue)
End Try
输出:
Exception: 6.084E+17 > 2.147484E+009.
示例2:
Dim value As Byte = 241
Try
Dim newValue As SByte = (CSByte(value))
Console.WriteLine("Converted the {0} value {1} to the {2} value {3}.", _
value.GetType().Name, value, _
newValue.GetType().Name, newValue)
Catch e As OverflowException
Console.WriteLine("Exception: {0} > {1}.", value, SByte.MaxValue)
End Try
输出:
Exception: 241 > 127.