Method IsSymbolOrCodeParsable
IsSymbolOrCodeParsable(string, out string?)
Checks whether the specified symbol/code can be reliably parsed. If this method returns false, then adding a currency that uses the symbol/code to a currency registry will cause parsing operations that depend on the offending symbol/code to throw an `InvalidOperationException, as it may otherwise result in unpredictable parsing errors or incorrect results.
Declaration
public static bool IsSymbolOrCodeParsable(string symbolOrCode, out string? error)
Parameters
Type | Name | Description |
---|---|---|
string | symbolOrCode | The symbol or code to check. |
string | error | When this method returns false, this will contain an error message that describes why the symbol or code is not parsable. |
Returns
Type | Description |
---|---|
bool |
Remarks
In order for a symbol or code to be considered parsable, it must not contain any of the following characters: '+'
, '-'
(minus sign),
'−'
(minus-hyphen), '('
or ')'
, numbers or whitespace (except for the non-breaking space character '\u202F'
).
You can use this method to pre-validate custom or user-provided symbols/codes that may be added to a registry that will be used for parsing to avoid ending up with a registry that can't be used for parsing later. Currencies and registries that contain unparsable symbols/codes can still be used for formatting monetary values and doing any other operations that do not involve parsing (including any lookup operations like TryGetCurrency(string, out Currency) and TryGetCurrenciesBySymbol(string, out IReadOnlyList<Currency>).