Convert Decimal to Int64 (long) in C#

CsharpProgrammingServer Side Programming

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 −


 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);


Converted Decimal '190.66' to Int64 value 191
Updated on 23-Jun-2020 06:50:42