Java
byte[] input = new byte[] { 83, 77, 45, 71, 57, 51, 53, 70 };
int buff = ByteBuffer.wrap(input).getInt();
Output: 1397566791
C#
byte [] array = { 83, 77, 45, 71, 57, 51, 53, 70 };
MemoryStream stream = new MemoryStream();
using (BinaryWriter writer = new BinaryWriter(stream))
{
writer.Write(array);
}
byte[] bytes = stream.ToArray();
int buff = BitConverter.ToInt32(bytes, 0);
Output: 1194151251
I have no idea how to get the same output
Thanks
Well,
Int32
consists of4
bytes only, let'sTake
them with the help ofTake(4)
. Next, we have to take ending (Big or Little) into account andReverse
these4
bytes if necessary: