在C#中将十进制转换为Int64(long)
使用Convert.ToInt64()方法在C#中将Decimal转换为Int64(长整数)。
假设我们有一个十进制变量。
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
热门推荐
6 保研的祝福语简短
10 年轻20岁祝福语简短
11 朋友结婚祝福语信息简短
12 女孩婚礼贺卡祝福语简短
13 30段点歌简短祝福语
14 虎年春节祝福语图文简短
15 写给后妈祝福语大全简短
16 简短回复生日祝福语
17 校长送毕业祝福语简短
18 毕业立体贺卡祝福语简短