// Convert a string into a byte value. public static byte FromString(String Value) { if (Value != null) { try { long lvalue; if (LongType.TryConvertHexOct(Value, out lvalue)) { return(checked ((byte)lvalue)); } return(Convert.ToByte (Math.Round(DoubleType.Parse(Value)))); } catch (OverflowException) { throw new InvalidCastException (String.Format (S._("VB_InvalidCast"), "System.String", "System.Byte")); } } else { return(0); } }
public static double FromString (String Value, NumberFormatInfo NumberFormat) { if (Value == null) { return(0.0); } try { long lvalue; if (LongType.TryConvertHexOct(Value, out lvalue)) { return((double)lvalue); } return(Parse(Value, NumberFormat)); } catch (FormatException) { throw new InvalidCastException (String.Format (S._("VB_InvalidCast"), "System.String", "System.Decimal")); } }