c# – ‘decimal’不包含’Round’的定义
发布时间:2020-12-15 23:50:07 所属栏目:百科 来源:网络整理
导读:C#的新手,并在第一次尝试使用Round方法时遇到此编译错误.有任何想法吗?谢谢: private void totalPoundsTextBox_TextChanged(object sender,TextChangedEventArgs e){ TextBox textBox = textBoxes[1]; decimal numericValue = textBoxNumberCheck(textBox,
C#的新手,并在第一次尝试使用Round方法时遇到此编译错误.有任何想法吗?谢谢:
private void totalPoundsTextBox_TextChanged(object sender,TextChangedEventArgs e) { TextBox textBox = textBoxes[1]; decimal numericValue = textBoxNumberCheck(textBox,0M,22046M,false); if (numericValue >= 0) ***weight.Kilos = decimal.Round(numericValue / 2.2046M,2,MidpointRounding.AwayFromZero);*** UpdateBoxValues(); } 解决方法
请改用Math.Round.
weight.Kilos = Math.Round(numericValue / 2.2046,MidpointRounding.AwayFromZero); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |