This documentation is archived and is not being maintained.

# Decimal.Explicit Operator

Visual Studio 2008

Converts a Decimal to a Unicode character.

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

## Syntax

```public static explicit operator char (
decimal value
)
```

#### Parameters

value
Type: System.Decimal

A Decimal to convert.

#### Return Value

Type: System.Char
A Unicode character that represents the converted Decimal.

## Exceptions

ExceptionCondition
OverflowException

value is less than Int16.MinValue or greater than Int16.MaxValue.

## Examples

The following code example converts Decimal numbers to Char values (Unicode characters) using the explicit Decimal to Char conversion.

```using System;

class Example
{
public static void Main( )
{
decimal[] values = { 3.33m, 55.5m, 77.7m, 123m, 123.999m, 170m,
188.88m, 222m, 244m, 8217m, 8250m, 65536m,
-1m };
Console.WriteLine("{0,17}{1,12}{2,19}", "Decimal Argument",
"Hex Code", "Char/Exception");
Console.WriteLine("{0,17}{1,12}{2,19}","----------------",
"--------", "--------------");
foreach (decimal value in values)
{
char charValue;

// Convert the number to a char value.
try {
charValue = (char) value;
Console.WriteLine("{0,17}{1,12:X4}{2,19}", value,
(ushort) charValue, charValue);
}
catch (OverflowException e) {
Console.WriteLine("{0,17}{1,31}", value, e.GetType().Name);
}
}
}
}
// The example displays the following output:
//     Decimal Argument    Hex Code     Char/Exception
//     ----------------    --------     --------------
//                 3.33        0003                  ?
//                 55.5        0037                  7
//                 77.7        004D                  M
//                  123        007B                  {
//              123.999        007B                  {
//                  170        00AA                  �
//               188.88        00BC                  �
//                  222        00DE                  �
//                  244        00F4                  �
//                 8217        2019                  �
//                 8250        203A                  �
//                65536              OverflowException
//                   -1              OverflowException
```

## Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

## Version Information

#### .NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0