ToDecimal Method (Char)

Convert.ToDecimal Method (Char)

[ 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.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public static decimal ToDecimal(
	char value
)

Parameters

value
Type: System.Char
A Unicode character.

Return Value

Type: System.Decimal
This conversion is not supported. No value is returned.

ExceptionCondition
InvalidCastException

This conversion is not supported.

This method is reserved for future use.

The following code sample attempts to convert a Char value to Decimal, throwing InvalidCastException upon failure.


public void ConvertCharDecimal(char charVal)
{
   Decimal decimalVal = 0;

   // Char to decimal conversion is not supported and will always
   // throw an InvalidCastException.
   try
   {
      decimalVal = System.Convert.ToDecimal(charVal);
   }
   catch (System.InvalidCastException)
   {
      outputBlock.Text += String.Format(
         "Char-to-decimal conversion is not supported " +
         "by the framework.") + "\n";
   }

   //Decimal to char conversion is also not supported.
   try
   {
      charVal = System.Convert.ToChar(decimalVal);
   }
   catch (System.InvalidCastException)
   {
      outputBlock.Text += String.Format(
         "Decimal-to-char conversion is not supported " +
         "by the framework.") + "\n";
   }
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft