Be clear of what you want. Be clear. You said "<0.5 set round off or > 0.5 add +1 in my decimal values", what happens to "0.5"? Let's follow this
Rounding Numbers[
^]
In c#, you can use
Math.Round with MidpointRounding.AwayFromZero option[
^] to achieve your desired rounding result.
But before that, you have to check the validity of the decimal number from the text box by using
Decimal.TryParse Method (String, Decimal) (System)[
^]. Putting things together, it looks like this:
using System;
public class Program
{
public static void Main()
{
string value;
decimal number;
value = "70.13";
if (Decimal.TryParse(value, out number))
Console.WriteLine(Math.Round(number,1,MidpointRounding.AwayFromZero));
else
Console.WriteLine("Unable to parse '{0}'.", value);
}
}