I have a table column "Amount" of type money. When I am retrieving its value through a store procedure, it returns the value upto 4 decimal places(because of type money). I want the value upto two decimal places and I want it to handle in the code. How will I do it by rounding off the value to 2 decimal place. Thanks
Rounding a decimal number to two decimal places is the same as rounding it to the hundredths place, which is the second place to the right of the decimal point. For example, 2.83620364 can be round to two decimal places as 2.84, and 0.7035 can be round to two decimal places as 0.70.
Read Custom Numeric Formats for detailed instructions on formatting numbers.
value.ToString("0.00");
In C# 6 or later, you can use string interpolation for a somewhat cleaner syntax.
$"{value:0.00}";
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