using System; public class HelloWorld { public static void Main(string[] args) { byte[] gByteAry = new byte[8] {1,2,3,4,5,6,7,8}; Int16 a, b, c, d; a = BitConverter.ToInt16(gByteAry, 6); // wordees(0) b = BitConverter.ToInt16(gByteAry, 4); // wordees(0) c = BitConverter.ToInt16(gByteAry, 2); // wordees(0) d = BitConverter.ToInt16(gByteAry, 0); // wordees(0) Console.WriteLine ("a = " + a.ToString("X4")); Console.WriteLine ("b = " + b.ToString("X4")); Console.WriteLine ("c = " + c.ToString("X4")); Console.WriteLine ("d = " + d.ToString("X4")); } }
a = 0807 b = 0605 c = 0403 d = 0201