UnitFormatUtils.TryParse
Description:
Parses a formatted string into a number with units if possible.
Parses a formatted string into a number with units if possible.
Overloads (8):
TryParse(Units,UnitType,String,ValueParsingOptions,Double,String)
[ObsoleteAttribute("This method is deprecated in Revit 2021 and may be removed in a future version of Revit. Please use the `TryParse(Units, ForgeTypeId, string, ValueParsingOptions, out double, out string)` overload instead.")]
public static bool TryParse(
Units units,
UnitType unitType,
string stringToParse,
ValueParsingOptions valueParsingOptions,
out double value,
out string message
)
-
unitsThe units formatting settings, typically obtained from Document.GetUnits().
-
unitTypeThe target unit type for the value.
-
StringstringToParseThe string to parse.
-
valueParsingOptionsAdditional parsing options.
-
Double%valueThe parsed value, in Revit's internal units. Ignore this value if the function returns false.
-
String%messageA localized message that, if the parsing fails, explains the reason for failure.
Return Value
bool
True if the string can be parsed, false otherwise.
-
unitType is an invalid unit type. See UnitUtils.IsValidUnitType() and UnitUtils.GetValidUnitTypes(). -or- The display unit in the FormatOptions in valueParsingOptions is not a valid display unit for unitType. See UnitUtils.IsValidDisplayUnit(UnitType, DisplayUnitType) and UnitUtils.GetValidDisplayUnits(UnitType).
-
A non-optional argument was NULL
-
A value passed for an enumeration argument is not a member of that enumeration