int value = 1234; byte[] bytes = BitConverter.GetBytes((short)value); if (BitConverter.IsLittleEndian == false) { Array.Reverse(bytes); } // Print the bytes in hexadecimal format Console.WriteLine(BitConverter.ToString(bytes));