-2

I have a decimal number: 12.4465463455

decimal value = 12.4465463455m;

How can I round this decimal and remove extra decimals but 2 so the decimal will be 12.45 ? Please notice I don't need a string. I know how to convert this to a string with 2 decimals and rounded. But have no idea how to manipulate the decimal variable itself.

user2818430
  • 5,853
  • 21
  • 82
  • 148

1 Answers1

4

Just use Math.Round, so:

decimal value = 12.4465463455m;
decimal value2dp = Math.Round(value, 2); //2 => 2 decimal places