Converts a string to a Decimal.
[Visual Basic] Overridable Public Function ToDecimal() As Decimal [C#] public virtual Decimal ToDecimal(); [C++] public: virtual Decimal ToDecimal(); [JScript] public function ToDecimal() : Decimal;
The Decimal with the value represented by value.
Exception Type | Condition |
---|---|
ArgumentException | If the string is null. |
FormatException | If the string does not contain a representation that can be converted to a Decimal using the Parse(String) method implemented by that type. |
OverflowException | If the string represents a number that is less than Decimal.MaxValue or greater than Decimal.MinValue. |
The ToDecimal implementation is the same as Parse and ToDecimal. (In addition information, see Decimal, Convert and Value.)
Note that if the beginning of the string contains a properly formatted numerical value, that will result in an overflow. In addition, the end of the string is improperly formed, it cannot be determined whether an OverflowException or a FormatException will be thrown. This has been implemented this way for performance reasons.