Convert.ToChar Method (Decimal)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Calling this method always throws InvalidCastException.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
- Type: System.Decimal
A Decimal number.
| Exception | Condition |
|---|---|
| InvalidCastException | This conversion is not supported. |
The following code sample attempts to convert a Decimal to Char, throwing InvalidCastException on failure.
Public Sub ConvertCharDecimal(ByVal charVal As Char) Dim decimalVal As [Decimal] = 0 ' Char to decimal conversion is not supported and will always ' throw an InvalidCastException. Try decimalVal = System.Convert.ToDecimal(charVal) Catch exception As System.InvalidCastException outputBlock.Text &= String.Format( _ "Char-to-decimal conversion is not supported " + _ "by the framework.") & vbCrLf End Try 'Decimal to char conversion is also not supported. Try charVal = System.Convert.ToChar(decimalVal) Catch exception As System.InvalidCastException outputBlock.Text &= String.Format( _ "Decimal-to-char conversion is not supported " + _ "by the framework.") & vbCrLf End Try End Sub
Show: