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