```
public int RoundOff (Decimal valueToRound)
{
return ((int)Math.Round(valueToRound / 10.0)) * 10;
}
```

12,244,802 members (48,712 online)

Email

Password

Sign in using

Int64 i = ((Int64)Math.Round(Convert.ToDecimal(dr["CHARGE"]) / 10,1,MidpointRounding.AwayFromZero)) * 10;

its working but one exception is

For 100's (eg: 100,200,300 etc), if we set charge as 105,205,etc its not rounding properly. Expected result: 110,120,130 etc, but now its displaying as 100,200,300 etc.

how can avoid this error ?

this is my requirement

95 to 104.9 --> 100

105 to 114.9 --> 110

Any answer is highly appreciated. thanks in advance.

Try:

```
public int RoundOff (Decimal valueToRound)
{
return ((int)Math.Round(valueToRound / 10.0)) * 10;
}
```

v2

```
if (Convert.ToDecimal(x % 10) == 5)
{
x = x + 1;
}
Int64 i = ((Int64)Math.Round(Convert.ToDecimal(x) / 10)) * 10;
```

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada
+1 416-849-8900 x 100