M

UnitFormatUtils.TryParse

Description:
Parses a formatted string into a number with units if possible.
public static bool TryParse(
	Units units,
	UnitType unitType,
	string stringToParse,
	out double value
)
Return Value bool True if the string can be parsed, false otherwise.
double GetLengthInput(Document document, String userInputLength)
{
    double dParsedLength = 0;
    Units units = document.GetUnits();
    // try to parse a user entered string (i.e. 100 mm, 1'6")
    bool parsed = UnitFormatUtils.TryParse(units, UnitType.UT_Length, userInputLength, out dParsedLength);
    if (parsed == true)
    {
        string msg = string.Format("User Input: {0}\r\nParsed value: {1}", userInputLength, dParsedLength);
        TaskDialog.Show("Parsed Data", msg);
    }

    return dParsedLength;
}