试图在VB.NET中将数字字符串转换为INT64。我正在测试的号码是12804494279291877304。
我收到的错误是"Value was either too large or too small for an Int64."
下面的代码示例。
BigInt = CLng(EncodeNumber)
答案 0 :(得分:6)
它太大,doesn't fix in a INT64。它将适合UINT64。
Dim v As UInt64
v = UInt64.Parse("12804494279291877304")
就像@Çöđěxěŕ所说的那样,使用TryParse允许使用适当的错误处理。
If Not UInt64.TryParse("12804494279291877304", v) Then
' Handle wrong input
End If
答案 1 :(得分:3)
您的电话号码对Int64
来说太大,因此可以使用BigInteger
,请参阅https://docs.microsoft.com/en-us/dotnet/api/system.numerics.biginteger?view=netframework-4.8
您可以像其他人建议的那样使用无符号的Int64,但是请注意,它不会包含负数,并且限制为18446744073709551615