Convert two bytes at a specified position in a byte array to a 16-bit signed integer
using System; class BytesToInt16Demo { const string formatter = "{0,5}{1,17}{2,10}"; public static void BAToInt16( byte[ ] bytes, int index ) { short value = BitConverter.ToInt16( bytes, index ); Console.WriteLine( formatter, index, BitConverter.ToString( bytes, index, 2 ), value ); } public static void Main( ) { byte[ ] byteArray = { 15, 0, 0, 128, 16, 39, 240, 216, 241, 255, 127 }; Console.WriteLine( BitConverter.ToString( byteArray ) ); BAToInt16( byteArray, 1 ); } }