Converts English decimal number words into System.Decimal values.
public static class WordsToDecimalNumberExtensionInheritance System.Object → WordsToDecimalNumberExtension
Converts English decimal number words containing one point 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 English 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 an English culture.
The integer part uses the existing English words-to-number grammar. The fractional part
requires one to 28 digit words (zero through nine); conjunctions are not
accepted after point. A leading minus or negative applies to the
complete value. The integer part may be omitted, as in point five.
A decimal marker and at least one fractional digit word are required.
Attempts to convert English 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 English culture to use for parsing.
System.Boolean
true if conversion succeeded; otherwise, false.
Attempts to convert English 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 English 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.