Skip to content

Instantly share code, notes, and snippets.

@DevJohnC
Created April 27, 2018 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DevJohnC/7612e6cb944a21977e128d4003b8be6b to your computer and use it in GitHub Desktop.
Save DevJohnC/7612e6cb944a21977e128d4003b8be6b to your computer and use it in GitHub Desktop.
public static class BigEndianBitConverter
{
public static UInt16 ToUInt16(byte[] value, int startIndex)
{
return (ushort)(
value[startIndex + 1] |
value[startIndex] << 8
);
}
public static UInt32 ToUInt32(byte[] value, int startIndex)
{
return (uint)(
value[startIndex + 3] |
value[startIndex + 2] << 8 |
value[startIndex + 1] << 16 |
value[startIndex] << 24
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment