Parse Int from byte array - CSharp System

CSharp examples for System:Byte Array

Description

Parse Int from byte array

Demo Code


using System.Text;
using System;//  w w  w . ja v  a 2 s.c o m

public class Main{
        public static bool ParseInt(this byte[] data, out int result, int offset, int length)
        {
            result = 0;
            var str = string.Empty;
            for (int i = offset; i < offset + length; i++)
            {
                str += (char)(data[i]);
            }
            int d;
            if (Parse.TryParseInt(str, out d))
            {
                result = d;
                return true;
            }
            return false;
        }
}

Related Tutorials