Convert byte array To Integer - CSharp System

CSharp examples for System:Byte Array

Description

Convert byte array To Integer

Demo Code


using System.Net;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  w w w.  j  a  v  a2 s. c  o  m*/

public class Main{
        public static int ToInteger(byte[] bytes)
        {
            int value = 0;
            for (int i = 0; i < bytes.Length; i++)
            {
                value <<= 8;
                value = value | (bytes[i] & 0xFF);
            }

            return ReverseBytes(value);
        }
}

Related Tutorials