Hi jaya23leo,
Refer below code.
C#
protected void Calculate(object sender, EventArgs e)
{
double d = 19745;
Response.Write(DoubleRound(d, -2) + "<br/>");
d = 19777;
Response.Write(DoubleRound(d, -2));
}
private double DoubleRound(double value, int digits)
{
if (digits >= 0)
{
return Math.Round(value, digits);
}
else
{
digits = Math.Abs(digits);
double temp = value / Math.Pow(10, digits);
temp = Math.Round(temp, 0);
return temp * Math.Pow(10, digits);
}
}
VB.Net
Protected Sub Calculate(ByVal sender As Object, ByVal e As EventArgs)
Dim d As Double = 19745
Response.Write(DoubleRound(d, -2) & "<br/>")
d = 19777
Response.Write(DoubleRound(d, -2))
End Sub
Private Function DoubleRound(ByVal value As Double, ByVal digits As Integer) As Double
If digits >= 0 Then
Return Math.Round(value, digits)
Else
digits = Math.Abs(digits)
Dim temp As Double = value / Math.Pow(10, digits)
temp = Math.Round(temp, 0)
Return temp * Math.Pow(10, digits)
End If
End Function
Output
19700
19800