Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting Decimal To Integer

Tags:

c#

asp.net

string retval;

retval = Decimal.ToInt32(1899.99M).ToString();

the output is 1899. But i want to if decimal is bigger .5 then output is 1900 else then ouput is 1899. how can i do this? thanks in advance !

like image 510
ozkank Avatar asked Jun 16 '26 20:06

ozkank


1 Answers

Use Math.Round first.

http://msdn.microsoft.com/en-us/library/system.math.round.aspx

like image 95
Assaf Avatar answered Jun 19 '26 09:06

Assaf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!