C# 将字符串转换为十进制数 (decimal) 的方法
可以使用 decimal.Parse() 或 decimal.TryParse() 方法将字符串类型转换为十进制数 (decimal) 类型。
例如:
string str = '123.45';
decimal result = decimal.Parse(str);
或者:
string str = '123.45';
decimal result;
if(decimal.TryParse(str, out result))
{
//转化成功
}
else
{
//转化失败
}
原文地址: https://www.cveoy.top/t/topic/n8xn 著作权归作者所有。请勿转载和采集!