本文整理匯總了VB.NET中System.Decimal.ToInt64方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Decimal.ToInt64方法的具體用法?VB.NET Decimal.ToInt64怎麽用?VB.NET Decimal.ToInt64使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Decimal
的用法示例。
在下文中一共展示了Decimal.ToInt64方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
Module Example
Public Sub Main()
Dim values() As Decimal = { 123d, New Decimal(123000, 0, 0, false, 3),
123.999d, 18446744073709551615.999d,
18446744073709551616d, 9223372036854775807.999d,
9223372036854775808d, -0.999d, -1d,
-9223372036854775808.999d,
-9223372036854775809d }
For Each value In values
Try
Dim number As Long = Decimal.ToInt64(value)
Console.WriteLine("{0} --> {1}", value, number)
Catch e As OverflowException
Console.WriteLine("{0}: {1}", e.GetType().Name, value)
End Try
Next
End Sub
End Module
輸出:
123 --> 123 123.000 --> 123 123.999 --> 123 OverflowException: 18446744073709551615.999 OverflowException: 18446744073709551616 9223372036854775807.999 --> 9223372036854775807 OverflowException: 9223372036854775808 -0.999 --> 0 -1 --> -1 -9223372036854775808.999 --> -9223372036854775808 OverflowException: -9223372036854775809