-6

I want to get the round off value of a decimal number Suppose I am getting 24.86 than i want to get 25 as final value

James
  • 172
  • 2
  • 10

2 Answers2

1

Look at Math.Round(decimal) and the overload which accepts a MidpointRounding argument.

Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288
0

Simply

Math.Round(24.86)

This will round you value to 25.

Your own logic will be

decimal d = 1.5m;
decimal r = d - Math.Truncate(d);

if (r > 0)
     r = 1 - r;

decimal value = d + r;
Nikhil Agrawal
  • 47,018
  • 22
  • 121
  • 208