且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我想将十进制值转换为最接近的十进制数

更新时间:2023-02-14 20:29:40

double noo = Convert.ToDouble(txttotalamount.Text);
noo = Math.Round(noo, 1);
                  
string numString = string.Format("{0:###0.00}", Math.Round(noo, 2, MidpointRounding.AwayFromZero));


try:

try:

roundnoo = Math.Round(noo, 2); 





or


转换十进制ToString(#.##")
这导致"12345.67"
从字符串中读取最后一个字符,并确定它应该向下还是向上(60或70)
Convert the decimal ToString("#.##")
this leads to "12345.67"
Read the last char from string and decide if it should be down or up (60 or 70)