Contact: aviboots(AT)netvision.net.il
41,604 questions
54,252 answers
573 users
using System; class Program { static void Main() { byte[] bytes = { 0, 1, 0, 0 }; int n = BitConverter.ToInt32(bytes, 0); Console.WriteLine(n); } } /* run: 256 */
using System; class Program { static void Main() { byte[] bytes = { 0, 0, 2, 1 }; // 2 * 256 + 1 if (BitConverter.IsLittleEndian) Array.Reverse(bytes); int n = BitConverter.ToInt32(bytes, 0); Console.WriteLine(n); } } /* run: 513 */