Parse Float from byte array - CSharp System

CSharp examples for System:Byte Array

Description

Parse Float from byte array

Demo Code


using System.Text;
using System;//  w  w w .j a  va  2  s . com

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

Related Tutorials