本文整理匯總了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.