I am working in c# and i do not want thing like this:
value = 1.658598554646 to value= 2
or
value = 1.2256485526 to value =1
I want to do something like :
value = 1.658598554646 to value = 1.7 //see upto one intger after point(.)
value = 1.2256485526 to value = 1.2
How to do that in c# ? Is there any way to achieve this ?
one decimal you can use Math.Round
, and set the number of decimal points you round it to,
decimal value = 1.658598554646;
OneDec = Math.Round(value , 1);
如何使用Math.Round
var result = Math.Round(value, 1);
您可以使用
decimal DEBITAMT = Math.Round(1.658598554646, 1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.