C# 中的 Decimal.ToUInt32() 方法
C# 中的 Decimal.ToUInt32() 方法用于将指定 Decimal 的值转换为等效的 32 位无符号整数。
语法
以下为语法 −
public static uint ToUInt32 (decimal val);
上方,Val 是要转换的十进制数。
示例
现在让我们看一个示例,实现 Decimal.ToUInt32() 方法 −
using System;
public class Demo {
public static void Main(){
Decimal val = 0.001m;
Console.WriteLine("Decimal value = "+val);
uint res = Decimal.ToUInt32(val);
Console.WriteLine("32-bit unsigned integer = "+res);
}
}输出
这将生成以下输出 −
Decimal value = 0.001 32-bit unsigned integer = 0
示例
现在我们再看另一个示例,实现 Decimal.ToUInt32() 方法 −
using System;
public class Demo {
public static void Main(){
Decimal val = 67.487m;
Console.WriteLine("Decimal value = "+val);
uint res = Decimal.ToUInt32(val);
Console.WriteLine("32-bit unsigned integer = "+res);
}
}输出
这将生成以下输出 −
Decimal value = 67.487 32-bit unsigned integer = 67
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言
C++
C#
MongoDB
MySQL
Javascript
PHP