/// <summary> /// Parses a double from the input string, converting it from a percentage to a decimal values. /// </summary> /// <param name="str"> the string to parse </param> /// <returns> the parsed value </returns> /// <exception cref="NumberFormatException"> if the string cannot be parsed </exception> public static double parseDoublePercent(string str) { try { return((new decimal(str)).movePointLeft(2).doubleValue()); } catch (System.FormatException ex) { System.FormatException nfex = new System.FormatException("Unable to parse percentage from '" + str + "'"); nfex.initCause(ex); throw nfex; } }
/// <summary> /// Parses an integer from the input string. /// </summary> /// <param name="str"> the string to parse </param> /// <returns> the parsed value </returns> /// <exception cref="NumberFormatException"> if the string cannot be parsed </exception> public static int parseInteger(string str) { try { return(int.Parse(str)); } catch (System.FormatException ex) { System.FormatException nfex = new System.FormatException("Unable to parse integer from '" + str + "'"); nfex.initCause(ex); throw nfex; } }