Export (0) Print
Expand All

Convert.ToChar Method (Decimal)

Calling this method always throws InvalidCastException.

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

public static char ToChar(
	decimal value
)

Parameters

value
Type: System.Decimal
A Decimal number.

Return Value

Type: System.Char
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 Decimal to Char, throwing InvalidCastException on 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";
   }
}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft