当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET Int64结构体代码示例

本文整理汇总了VB.NET中System.Int64结构体的典型用法代码示例。如果您正苦于以下问题:VB.NET Int64结构体的具体用法?VB.NET Int64怎么用?VB.NET Int64使用的例子?那么恭喜您, 这里精选的结构体代码示例或许可以为您提供帮助。


在下文中一共展示了Int64结构体的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1:

Dim value1 As SByte = 124
Dim value2 As Int16 = 1618
Dim value3 As Int32 = Int32.MaxValue

Dim number1 As Long = value1
Dim number2 As Long = value2
Dim number3 As Long = value3
开发者ID:VB.NET开发者,项目名称:System,代码行数:7,代码来源:Int64

示例2: CLng

Dim ulNumber As ULong = 163245617943825
Try
   Dim number1 As Long = CLng(ulNumber)
   Console.WriteLine(number1)
Catch e As OverflowException
   Console.WriteLine("{0} is out of range of an Int64.", ulNumber)
End Try

Dim dbl2 As Double = 35901.997
Try
   Dim number2 As Long = CLng(dbl2)
   Console.WriteLine(number2)
Catch e As OverflowException
   Console.WriteLine("{0} is out of range of an Int64.", dbl2)
End Try
   
Dim bigNumber As BigInteger = 1.63201978555e30
Try
   Dim number3 As Long = CLng(bigNumber)
   Console.WriteLine(number3)
Catch e As OverflowException
   Console.WriteLine("{0:N0} is out of range of an Int64.", bigNumber)
End Try
开发者ID:VB.NET开发者,项目名称:System,代码行数:23,代码来源:Int64

输出:

163245617943825
35902
1,632,019,785,549,999,969,612,091,883,520 is out of range of an Int64.

示例3: values

Dim values() As Decimal = { Decimal.MinValue, -1034.23d, -12d, 0d, 147d, _
                            199.55d, 9214.16d, Decimal.MaxValue }
Dim result As Long

For Each value As Decimal In values
   Try
      result = Convert.ToInt64(value)
      Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
                        value.GetType().Name, value, _
                        result.GetType().Name, result)
   Catch e As OverflowException
      Console.WriteLine("{0} is outside the range of the Int64 type.", _
                        value)
   End Try   
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:15,代码来源:Int64

输出:

-79228162514264337593543950335 is outside the range of the Int64 type.
Converted the Decimal value '-1034.23' to the Int64 value -1034.
Converted the Decimal value '-12' to the Int64 value -12.
Converted the Decimal value '0' to the Int64 value 0.
Converted the Decimal value '147' to the Int64 value 147.
Converted the Decimal value '199.55' to the Int64 value 200.
Converted the Decimal value '9214.16' to the Int64 value 9214.
79228162514264337593543950335 is outside the range of the Int64 type.

示例4:

Dim string1 As String = "244681903147"
Try
   Dim number1 As Long = Int64.Parse(string1)
   Console.WriteLine(number1)
Catch e As OverflowException
   Console.WriteLine("'{0}' is out of range of a 64-bit integer.", string1)
Catch e As FormatException
   Console.WriteLine("The format of '{0}' is invalid.", string1)
End Try

Dim string2 As String = "F9A3CFF0A"
Try
   Dim number2 As Long = Int64.Parse(string2,
                            System.Globalization.NumberStyles.HexNumber)
   Console.WriteLine(number2)
Catch e As OverflowException
   Console.WriteLine("'{0}' is out of range of a 64-bit integer.", string2)
Catch e As FormatException
   Console.WriteLine("The format of '{0}' is invalid.", string2)
End Try
开发者ID:VB.NET开发者,项目名称:System,代码行数:20,代码来源:Int64

输出:

244681903147
67012198154

示例5: numbers

Dim numbers() As Long = { -1403, 0, 169, 1483104 }
For Each number In numbers
   ' Display value using default formatting.
   Console.Write("{0,-8}  -->   ", number.ToString())
   ' Display value with 3 digits and leading zeros.
   Console.Write("{0,8:D3}", number)
   ' Display value with 1 decimal digit.
   Console.Write("{0,13:N1}", number) 
   ' Display value as hexadecimal.
   Console.Write("{0,18:X2}", number)
   ' Display value with eight hexadecimal digits.
   Console.WriteLine("{0,18:X8}", number)
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:13,代码来源:Int64

输出:

-1403     -->      -1403     -1,403.0  FFFFFFFFFFFFFA85  FFFFFFFFFFFFFA85
0         -->        000          0.0                00          00000000
169       -->        169        169.0                A9          000000A9
1483104   -->    1483104  1,483,104.0            16A160          0016A160

示例6: numbers

Dim numbers() As Long = { -146, 11043, 2781913 }
For Each number In numbers
   Console.WriteLine("{0} (Base 10):", number)
   Console.WriteLine("   Binary:  {0}", Convert.ToString(number, 2))
   Console.WriteLine("   Octal:   {0}", Convert.ToString(number, 8))
   Console.WriteLine("   Hex:     {0}", Convert.ToString(number, 16))
   Console.WriteLine()
Next
开发者ID:VB.NET开发者,项目名称:System,代码行数:8,代码来源:Int64

输出:

-146 (Base 10):
Binary:  1111111111111111111111111111111111111111111111111111111101101110
Octal:   1777777777777777777556
Hex:     ffffffffffffff6e

11043 (Base 10):
Binary:  10101100100011
Octal:   25443
Hex:     2b23

2781913 (Base 10):
Binary:  1010100111001011011001
Octal:   12471331
Hex:     2a72d9


注:本文中的System.Int64结构体示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。