在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
热门推荐
10 感谢韩语老师祝福语简短
11 升职文案高级祝福语简短
12 花童结婚祝福语大全简短
13 向国庆送祝福语简短
14 什么寄语简短祝福语女生
15 客户回礼祝福语大全简短
16 女孩生日祝福语简短创意
17 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短