C#以下方法或属性之间的调用不明确:’System.Math.Round(double,int)’和’System.Math.Round(decimal,int)
由于以下错误,我的代码无法编译:
以下方法或属性之间的调用不明确:’System.Math.Round(double,int)’和’System.Math.Round(decimal,int)
我的代码是
Math.Round(new FileInfo(strFilePath).Length / 1024, 1)
我怎样才能解决这个问题?
谢谢
问题是你进行整数除法(结果也是int
), int
可以隐式转换为double
和decimal
。 因此,您需要确保表达式导致其中一个; double
可能是你想要的。
上述就是C#学习教程:C#以下方法或属性之间的调用不明确:’System.Math.Round(double,int)’和’System.Math.Round(decimal,int)分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
Math.Round(new FileInfo(strFilePath).Length / 1024.0, 1)
Math.Round(new FileInfo(strFilePath).Length / 1024d, 1)
Math.Round((double) (new FileInfo(strFilePath).Length / 1024), 1)
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/953572.html