在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 好听的元旦简短祝福语