在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 生日广州男生祝福语简短