How can I round a decimal
to at least 2 decimal places and have it kept as a decimal
?
I know I can do this, but it has a code smell.
var myResult = Decimal.Parse(myDecimal.ToString("0.00##"));
These are the expected results.
0.028 -> 0.028
0.02999 -> 0.03
You can use
Math.Round(myResult, 4);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With