Implicit Conversion (SByte to Decimal)

# Decimal Implicit Conversion (SByte to Decimal)

Silverlight

Converts an 8-bit signed integer to a Decimal.

This API is not CLS-compliant.

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

## Syntax

```public static implicit operator decimal (
sbyte value
)
```

#### Parameters

value
Type: System.SByte
An 8-bit signed integer.

#### Return Value

Type: System.Decimal
A Decimal that represents the converted 8-bit signed integer.

## Examples

The following code example converts SByte values to Decimal numbers using the SByte to Decimal conversion. This conversion is implicit in C#, but requires the op_Implicit operator in Visual Basic and C++. Implicit conversions to Decimal use other methods in these languages.

```
// Example of the implicit conversion from sbyte to decimal.
using System;

class Example
{
const string formatter =
"{0,15}{1,15}{2,10:X8}{3,9:X8}{4,9:X8}{5,9:X8}";

// Convert the sbyte argument and display the decimal value.
public static void DecimalFromSByte(System.Windows.Controls.TextBlock outputBlock, sbyte argument)
{
decimal decValue;
int[] bits;

// Display the decimal and its binary representation.
decValue = argument;
bits = decimal.GetBits(decValue);

outputBlock.Text += String.Format(formatter, argument, decValue,
bits[3], bits[2], bits[1], bits[0]) + "\n";
}

public static void Demo(System.Windows.Controls.TextBlock outputBlock)
{
outputBlock.Text += String.Format(
"This example of the implicit conversion from sbyte " +
"to decimal generates the \nfollowing output. It " +
"displays the decimal value and its binary " +
"representation.\n") + "\n";
outputBlock.Text += String.Format(formatter, "sbyte argument",
"decimal value", "bits[3]", "bits[2]",
"bits[1]", "bits[0]") + "\n";
outputBlock.Text += String.Format(formatter, "--------------",
"-------------", "-------", "-------",
"-------", "-------") + "\n";

// Convert sbyte values and display the results.
DecimalFromSByte(outputBlock, sbyte.MinValue);
DecimalFromSByte(outputBlock, sbyte.MaxValue);
DecimalFromSByte(outputBlock, 0x3F);
DecimalFromSByte(outputBlock, 123);
DecimalFromSByte(outputBlock, -100);
}
}

/*
This example of the implicit conversion from sbyte to decimal generates the
following output. It displays the decimal value and its binary representation.

sbyte argument  decimal value   bits[3]  bits[2]  bits[1]  bits[0]
--------------  -------------   -------  -------  -------  -------
-128           -128  80000000 00000000 00000000 00000080
127            127  00000000 00000000 00000000 0000007F
63             63  00000000 00000000 00000000 0000003F
123            123  00000000 00000000 00000000 0000007B
-100           -100  80000000 00000000 00000000 00000064
*/

```

## Version Information

#### 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

## Platforms

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