This overload differs from the Decimal..::.Parse(String, NumberStyles, IFormatProvider) method by returning a Boolean value that indicates whether the parse operation succeeded instead of returning the parsed numeric value. It eliminates the need to use exception handling to test for a FormatException in the event that s is invalid and cannot be successfully parsed.
The style parameter defines the allowable format of the s parameter for the parse operation to succeed. It must be a combination of bit flags from the NumberStyles enumeration. The following NumberStyles members are not supported:
Depending on the value of style, the s parameter may include the following elements:
[ws][$][sign][digits,]digits[.fractional-digits][e[sign]digits][ws]
Elements in square brackets ([ and ]) are optional. The following table describes each element.
The style parameter specifies the permitted format of the s parameter, and can be one or more NumberStyles enumerated constants combined using a bitwise OR operation. If style is null, s is interpreted using the NumberStyles..::.Number style.
The provider parameter is an IFormatProvider implementation such as a NumberFormatInfo or CultureInfo object. The provider parameter supplies culture-specific information used in parsing. If provider is nullNothingnullptra null reference (Nothing in Visual Basic), the thread current culture is used.
A Decimal object has 29 digits of precision. If s represents a number that has more than 29 digits, but has a fractional part and is within the range of MaxValue and MinValue, the number is rounded, not truncated, to 29 digits using rounding to nearest.
If a separator is encountered in the s parameter during a parse operation, and the applicable currency or number decimal and group separators are the same, the parse operation assumes that the separator is a decimal separator rather than a group separator. For more information about separators, see CurrencyDecimalSeparator, NumberDecimalSeparator, CurrencyGroupSeparator, and NumberGroupSeparator.