我在第一步(i = 0)出現「OverflowException」錯誤。這段代碼有什麼問題?BitConverter.ToInt64 OverflowException
Dim byteArray As Byte() = { _
0, 54, 101, 196, 255, 255, 255, 255, 0, 0, _
0, 0, 0, 0, 0, 0, 128, 0, 202, 154, _
59, 0, 0, 0, 0, 1, 0, 0, 0, 0, _
255, 255, 255, 255, 1, 0, 0, 255, 255, 255, _
255, 255, 255, 255, 127, 86, 85, 85, 85, 85, _
85, 255, 255, 170, 170, 170, 170, 170, 170, 0, _
0, 100, 167, 179, 182, 224, 13, 0, 0, 156, _
88, 76, 73, 31, 242}
Dim UintList As New List(Of UInt64)
For i As Integer = 0 To byteArray.Count - 1 Step 8
UintList.Add(BitConverter.ToInt64(byteArray, i))
Next
你確定這不是'ArgumentException'? – dasblinkenlight
http://stackoverflow.com/questions/9804265/how-does-bitconverter-toint64-handles-a-byte-arry-with-32-bytes-a-256-bit-hash –
把選項嚴格打開在頂部的源代碼文件,讓編譯器幫助你發現爲什麼這是錯誤的。這不是BitConverter引發此異常。它是從Int64到UInt64的無效轉換。改用BitConverter.ToUInt64()。或者,也許你想List(Of Int64),意圖很難猜測。 –