Converts localized decimal number words into System.Decimal values.
public static class WordsToDecimalNumberExtensionInheritance System.Object → WordsToDecimalNumberExtension
Converts localized decimal number words containing one locale-specific decimal marker to a decimal value.
public static decimal ToDecimalNumber(this string words, System.Globalization.CultureInfo culture);words System.String
The decimal number words to convert.
culture System.Globalization.CultureInfo
The culture to use for parsing.
System.Decimal
The parsed decimal value, including its authored fractional scale.
System.ArgumentNullException
If words is null.
System.FormatException
If the phrase is malformed or outside the supported System.Decimal range.
System.NotSupportedException
If culture is not supported.
The integer part uses the selected culture's words-to-number grammar. The fractional part requires one to 28 localized digit words. A supported negative affix applies to the complete value. The integer part may be omitted. A decimal marker and at least one fractional digit word are required. Markers and digit words follow the selected grammar's token boundaries. English scale phrases may exceed the System.Int64 range when the result fits in a System.Decimal; other cultures use the range supported by their words-to-number grammar.
Attempts to convert localized decimal number words without throwing for malformed input, unsupported cultures, or values outside the supported System.Decimal range.
public static bool TryToDecimalNumber(this string words, out decimal parsedNumber, System.Globalization.CultureInfo culture);words System.String
The decimal number words to convert.
parsedNumber System.Decimal
When this method returns, contains the parsed value if successful; otherwise, zero.
culture System.Globalization.CultureInfo
The culture to use for parsing.
System.Boolean
true if conversion succeeded; otherwise, false.
Attempts to convert localized decimal number words and reports the first unrecognized token.
public static bool TryToDecimalNumber(this string words, out decimal parsedNumber, System.Globalization.CultureInfo culture, out string? unrecognizedWord);words System.String
The decimal number words to convert.
parsedNumber System.Decimal
When this method returns, contains the parsed value if successful; otherwise, zero.
culture System.Globalization.CultureInfo
The culture to use for parsing.
unrecognizedWord System.String
When conversion fails, the best-effort unrecognized token or phrase.
System.Boolean
true if conversion succeeded; otherwise, false.