在C#中将指定的Decimal的值转换为等效的16位无符号整数
要将指定的Decimal的值转换为等效的16位无符号整数,代码如下-
示例
using System;
public class Demo {
public static void Main() {
Decimal val = 875.647m;
Console.WriteLine("Decimal value = "+val);
ushort res = Decimal.ToUInt16(val);
Console.WriteLine("16-bit unsigned integer = "+res);
}
}输出结果
这将产生以下输出-
Decimal value = 875.647 16-bit unsigned integer = 875
示例
让我们看另一个例子-
using System;
public class Demo {
public static void Main() {
Decimal val = 0.001m;
Console.WriteLine("Decimal value = "+val);
ushort res = Decimal.ToUInt16(val);
Console.WriteLine("16-bit unsigned integer = "+res);
}
}输出结果
这将产生以下输出-
Decimal value = 0.001 16-bit unsigned integer = 0
热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短