在asp.net中以价格(00)结束 [英] round off with (00) after price in asp.net

查看:63
本文介绍了在asp.net中以价格(00)结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

i的价格类似于



例如:55.65或23.23



我想要关闭如果,所以它会显示为



55.65 = 56


23.23 = 23



然后显示为56,00和23,00





如果价格为1000则显示为1,000









问候

maulik shah

解决方案

我认为你真的不需要完善任何东西。我认为你需要提出一些舍入值,这是不一样的。这只是表示某个数值的字符串的正确格式化问题。请参阅:

http:// msdn。 microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/0c899ak8(v = vs.110)的.aspx [<一个href =http://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx\"target =_ blanktitle =New Window> ^ ]。



这种方法(当你从未明确地舍入任何东西时)有一个重要的好处:你不会冒险在进一步的计算中使用舍入值,这可能会意外地造成一些损失准确性。只是格式化,你不会出错,因为舍入实际上是隐藏的,它发生在 ToString(字符串)里面。



-SA


您好,



您可以尝试这种方式



首先将模块(%)的十进制数加1,这样我就可以检查余数是否大于或小于0.5。取决于条件我舍入给定的十进制数。



< br /> 
decimal val = 512432435.65m;< br />
decimal ulti =( (val%1)> 0.5m?val - (val%1)+ 1:val - (val%1));< br />
Console.WriteLine(ulti.ToString(#,# #0.00 ##));< br />



谢谢




轮次

  int  finalprice = Convert.ToInt32(Math.Round( 55  65  0 ));  //   56  
int finalprice1 = Convert.ToInt32(Math.Round( 55 5 ,MidpointRounding.AwayFromZero)); // 56
int finalprice2 =转换。 ToInt32(Math.Round( 23 23 0 )); // 23



货币分隔符请点击链接

http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx [ ^ ]


Hi
i have a price like

eg.: 55.65 or 23.23

I want to round off if , so it will show as

55.65 = 56

23.23 = 23

and then show as 56,00 and 23,00


also if price is 1000 show as 1,000




regards
maulik shah

解决方案

I don't think you really need to round off anything. I think you need to present some rounded value, and this is no the same. This is just a matter of proper formatting of the string representing some numeric value. Please see:
http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx[^].

This approach (when you never explicitly round off anything) has one important benefit: you don't risk using the rounded value in further calculations, which could accidentally cause some loss of accuracy. With just formatting, you cannot go wrong, because rounding is actually hidden from you, it happens inside ToString(string).

—SA


Hello ,

You can try this way

firstly module (%) the decimal number by 1 , so that i can check whether the remainder is greater than or less than 0.5 . depending upon the condition i rounding off the given decimal no.

<br />
decimal val = 512432435.65m;<br />
decimal ulti = ((val % 1) > 0.5m ? val - (val % 1) + 1 : val - (val % 1));<br />
Console.WriteLine(ulti.ToString("#,##0.00##"));<br />


thanks


Hi,
For round of

int finalprice =Convert.ToInt32( Math.Round(55.65, 0));//56
       int finalprice1 = Convert.ToInt32(Math.Round(55.5, MidpointRounding.AwayFromZero));//56
       int finalprice2 = Convert.ToInt32(Math.Round(23.23, 0));//23


For currency separator follow the link
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx[^]


这篇关于在asp.net中以价格(00)结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆