Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Decimal Implicit Conversion (Byte to Decimal)

 

Defines an implicit conversion of an 8-bit unsigned integer to a Decimal.

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

public static implicit operator decimal (
	byte value
)

Parameters

value
Type: System.Byte

The 8-bit unsigned integer to convert.

Return Value

Type: System.Decimal

The converted 8-bit unsigned integer.

The overloads of the Implicit method define the types from which the compiler can automatically convert a Decimal value without an explicit casting operator (in C#) or a call to a conversion function (in Visual Basic). They are widening conversions that do not involve data loss and do not throw an OverflowException exception.

The following example converts Byte values to Decimal numbers.

using System;

class Example
{
    public static void Main()
    {
        // Define an array of byte values.
        byte[] values = { byte.MinValue, byte.MaxValue, 
                          0x3F, 123, 200 };   
        // Convert each value to a Decimal.
        foreach (var value in values) {
           decimal decValue = value;
           Console.WriteLine("{0} ({1}) --> {2} ({3})", value,
                             value.GetType().Name, decValue,
                             decValue.GetType().Name);         
        }
    }
}
// The example displays the following output:
//       0 (Byte) --> 0 (Decimal)
//       255 (Byte) --> 255 (Decimal)
//       63 (Byte) --> 63 (Decimal)
//       123 (Byte) --> 123 (Decimal)
//       200 (Byte) --> 200 (Decimal)

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2016 Microsoft