public static float?GetFloat(object val, bool parse, string fmt) { if (val == null) { return(null); } try { TypeCode tc = val.GetTypeCode(); switch (tc) { case TypeCode.Single: return(Convert.ToSingle(val)); case TypeCode.Double: return(DoubleToFloat(Convert.ToDouble(val))); case TypeCode.String: if (!parse) { return(null); } float n; if (!TryFromServer(Convert.ToString(val), out n, 0)) { return(null); } return(n); default: if (IsNumeric(tc)) { return(Convert.ToSingle(val)); } byte[] b = val as byte[]; int ix = 0; if (b?.Length == sizeof(float)) { return(IOEx.GetSingle(b, ref ix)); } return(null); } } catch { return(null); } }