C#에서 Decimal을 Int64(long)로 변환하려면 Convert.ToInt64() 메서드를 사용하세요.
10진수 변수가 있다고 가정해 보겠습니다.
decimal d = 310.23m;
이제 Int64로 변환하려면 Convert.ToInt64() 메서드를 사용하십시오.
long res; res = Convert.ToInt64(d);
다른 예를 살펴보겠습니다 -
예
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