UnitFormatUtilsTryParse(Units, ForgeTypeId, String, ValueParsingOptions, Double, String) Method |
Parses a formatted string into a number with units if possible.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic static bool TryParse(
Units units,
ForgeTypeId specTypeId,
string stringToParse,
ValueParsingOptions valueParsingOptions,
out double value,
out string message
)
Public Shared Function TryParse (
units As Units,
specTypeId As ForgeTypeId,
stringToParse As String,
valueParsingOptions As ValueParsingOptions,
<OutAttribute> ByRef value As Double,
<OutAttribute> ByRef message As String
) As Boolean
public:
static bool TryParse(
Units^ units,
ForgeTypeId^ specTypeId,
String^ stringToParse,
ValueParsingOptions^ valueParsingOptions,
[OutAttribute] double% value,
[OutAttribute] String^% message
)
static member TryParse :
units : Units *
specTypeId : ForgeTypeId *
stringToParse : string *
valueParsingOptions : ValueParsingOptions *
value : float byref *
message : string byref -> bool
Parameters
- units Units
-
The units formatting settings, typically obtained from Document.GetUnits().
- specTypeId ForgeTypeId
-
Identifier of the target spec for the value.
- stringToParse String
-
The string to parse.
- valueParsingOptions ValueParsingOptions
-
Additional parsing options.
- value Double
-
The parsed value. Ignore this value if the function returns false.
- message String
-
A localized message that, if the parsing fails, explains the reason for failure.
Return Value
Boolean
True if the string can be parsed, false otherwise.
ExceptionsException | Condition |
---|
ArgumentException |
specTypeId is not a measurable spec identifier. See UnitUtils.IsMeasurableSpec(ForgeTypeId).
-or-
The unit in the FormatOptions in valueParsingOptions is not a valid unit for specTypeId. See UnitUtils.IsValidUnit(ForgeTypeId, ForgeTypeId) and UnitUtils.GetValidUnits(ForgeTypeId).
|
ArgumentNullException |
A non-optional argument was null
|
See Also