C# Decimal Explicit(Decimal to Int64)

Description

Decimal Explicit(Decimal to Int64) defines an explicit conversion of a Decimal to a 64-bit signed integer.

Syntax

Decimal.Explicit(Decimal to Int64) has the following syntax.


public static explicit operator long (
  decimal value
)

Parameters

Decimal.Explicit(Decimal to Int64) has the following parameters.

  • value - The value to convert.

Returns

Decimal.Explicit(Decimal to Int64) method returns A 64-bit signed integer that represents the converted Decimal.

Example

The following example converts Decimal numbers to Int64 values by using the explicit Decimal to Int64 conversion.


using System;/*from  w  w  w.j  a  va 2 s  .  co  m*/

class MainClass
{
    public static void Main( )
    {
        object Int64Value;
        object UInt64Value;

        Int64Value = (long)123.999M;
        // Convert the argument to a ulong value. 
        UInt64Value = (ulong)123.999M;
        Console.WriteLine(Int64Value);
        Console.WriteLine(UInt64Value );

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version