简体   繁体   English

decimal.Round和Math.Round之间的区别

[英]Difference between decimal.Round and Math.Round

C#中Math.Round和decimal.Round函数有什么区别?

There is no difference. 没有区别。

Math.Round(decimal) source code: Math.Round(decimal)源代码:

public static Decimal Round(Decimal d) {
        return Decimal.Round(d,0);
}

Reference Source .NET Framework 参考源.NET Framework

EDIT: 编辑:

To clarify, source code for decimal.cs class: 为了澄清, decimal.cs类的源代码:

public static Decimal Round(Decimal d) {
        return Round(d, 0);
}

是的,答案明智没有区别但传递值是不同的Math.Round接受double和float但decimal.Round只接受十进制struct

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM