Convert.ToString Method (Decimal)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Converts the value of the specified Decimal number to its equivalent String representation.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
- Type: System.Decimal
A Decimal number.
This implementation is identical to Decimal.ToString.
The following code sample illustrates the conversion of a Decimal to a String, using ToString.
Public Sub ConvertStringDecimal(ByVal stringVal As String) Dim decimalVal As Decimal = 0 Try decimalVal = System.Convert.ToDecimal(stringVal) outputBlock.Text &= String.Format("The string as a decimal is {0}.", _ decimalVal) & vbCrLf Catch exception As System.OverflowException outputBlock.Text &= String.Format( _ "Overflow in string-to-decimal conversion.") & vbCrLf Catch exception As System.FormatException outputBlock.Text &= String.Format( _ "The string is not formatted as a decimal.") & vbCrLf Catch exception As System.ArgumentException outputBlock.Text &= "The string is null." & vbCrLf End Try ' Decimal to string conversion will not overflow. stringVal = System.Convert.ToString(decimalVal) outputBlock.Text &= String.Format("The decimal as a string is {0}.", _ stringVal) & vbCrLf End Sub
Show: