作者:VB.NET开发
项目:Syste
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
作者:VB.NET开发
项目:Syste
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