Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Visual Basic.NET 中 ULong.MaxValue=18,446,744,073,709,551,615。
以下代码运行良好:
Dim a As ULong = ULong.MaxValue
以下代码返回数字溢出错误
Dim b As ULong = 18446744073709551615
是什么导致了这个错误?
编译器假定任何太大而不能成为 a 的整数Integer是 a Long,当然你的数字不适合 a Long。您需要将 UL 后缀添加到文字编号以表明它是ULong而不只是Long.
Integer
Long
ULong
Dim b As ULong = 18446744073709551615UL