我使用以下代码来使用BinaryReader读取BigEndian信息,但我不确定这是否是高效的方法。是否有更好的解决方案?
这是我的代码:
这是我的代码:
我使用以下代码来使用BinaryReader
读取BigEndian信息,但我不确定这是否是高效的方法。是否有更好的解决方案?
这是我的代码:
// some code to initialize the stream value
// set the length value to the Int32 size
BinaryReader reader =new BinaryReader(stream);
byte[] bytes = reader.ReadBytes(length);
Array.Reverse(bytes);
int result = System.BitConverter.ToInt32(temp, 0);
ReadBytes
,然后使用不同的i
在数组中的不同位置读取整数。但这是一种优化,您应该在基准测试之后才能采取。 - CodesInChaos