using System.Globalization;
public static void Main()
Console.WriteLine($"125.00m --> {125.00m.RoundDownToNearest(0.25m).ToTrimmedString()}");
Console.WriteLine($"125.25m --> {125.25m.RoundDownToNearest(0.25m).ToTrimmedString()}");
Console.WriteLine($"125.33m --> {125.33m.RoundDownToNearest(0.25m).ToTrimmedString()}");
Console.WriteLine($"125.50m --> {125.50m.RoundDownToNearest(0.25m).ToTrimmedString()}");
Console.WriteLine($"125.66m --> {125.66m.RoundDownToNearest(0.25m).ToTrimmedString()}");
Console.WriteLine($"125.75m --> {125.75m.RoundDownToNearest(0.25m).ToTrimmedString()}");
Console.WriteLine($"125.99m --> {125.99m.RoundDownToNearest(0.25m).ToTrimmedString()}");
public static decimal RoundDownToNearest(this decimal passednumber, decimal roundto)
return Math.Floor(passednumber / roundto) * roundto;
public static string ToTrimmedString(this decimal amount)
var output = amount.ToString(CultureInfo.InvariantCulture);
return output.Contains(".") ?
output.TrimEnd('0').TrimEnd('.') :