public static void Main()
Console.WriteLine("Rounding 18.90 - Result =" +getRound(Convert.ToDecimal(18.90)));
Console.WriteLine("Rounding 18.30 - Result =" +getRound(Convert.ToDecimal(18.30)));
Console.WriteLine("Rounding 18.51 - Result =" +getRound(Convert.ToDecimal(18.51)));
Console.WriteLine("Rounding 18.49 - Result =" +getRound(Convert.ToDecimal(18.49)));
Console.WriteLine("Rounding 18.50 - Result =" +getRound(Convert.ToDecimal(18.50)));
public static decimal getRound(decimal decAmt)
decimal decPortion = Convert.ToDecimal(decAmt) - Convert.ToDecimal(Math.Floor(decAmt));
decimal intPortion = Convert.ToDecimal(Math.Floor(decAmt));
if (decPortion > (Decimal)0 && decPortion < (decimal)0.50)
else if (decPortion >= (Decimal)0.50)
return intPortion + decPortion;