C# Decimal ToInt64

Description

Decimal ToInt64 converts the value of the specified Decimal to the equivalent 64-bit signed integer.

Syntax

Decimal.ToInt64 has the following syntax.


public static long ToInt64(
  decimal d
)

Parameters

Decimal.ToInt64 has the following parameters.

  • d - The decimal number to convert.

Returns

Decimal.ToInt64 method returns A 64-bit signed integer equivalent to the value of d.

Example

The following example uses the ToInt64 method to convert decimal numbers to Int64 values.


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

class Example
{
   public static void Main( )
   {
      long number = Decimal.ToInt64(123.999m);
      Console.WriteLine(number);       
   }
}

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