Convert Decimal to Int64 (long) in C#



Use the Convert.ToInt64() method to convert Decimal to Int64 (long) in C#.

Let’s say we have a decimal variable.

decimal d = 310.23m;

Now to convert it to Int64, use the Convert.ToInt64() method.

long res;
res = Convert.ToInt64(d);

Let us see another example −

Example

 Live Demo

using System;
class Demo {
   static void Main() {
      decimal d = 190.66m;
      long res;
      res = Convert.ToInt64(d);
      Console.WriteLine("Converted Decimal '{0}' to Int64 value {1}", d, res);
   }
}

Output

Converted Decimal '190.66' to Int64 value 191
Updated on: 2020-06-23T06:50:42+05:30

8K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements