Byte[] byteSource = System.IO.File.ReadAllBytes(FileInputPath);
int fileOffset = BitConverter.ToInt32(byteSource);
我想轉換字節數組爲int但其顯示的錯誤轉換字節[]爲int在C#
Byte[] byteSource = System.IO.File.ReadAllBytes(FileInputPath);
int fileOffset = BitConverter.ToInt32(byteSource);
我想轉換字節數組爲int但其顯示的錯誤轉換字節[]爲int在C#
「否Toint32重載方法」沒有的ToInt32
超負荷採取單一的參數。 The method需要數組和開始索引。
int fileOffset = BitConverter.ToInt32(byteSource, 0);
謝謝@Andrei其作品 –
但轉換後有一個問題'fileOffset'和'byteSource'的大小是不同的。爲什麼? –
@RaaJivYadav,有什麼不同? – Andrei
是的,沒有方法過載的單個參數。您還需要指定偏移值。
int fileOffset = BitConverter.ToInt32(byteSource, 0);
如果你讀完整個錯誤,它會告訴你到底發生了什麼錯誤。 – CodeCaster