我正在努力完成Money,但我不知道这样做。那么,我怎样才能完成这些 示例 - 22.32 至 20.00 或 156.32 至 150.00 或 23556.00 至 23550.00
我正在实施此代码...
class Program
{
static void Main(string[] args)
{
double a = 22.58;
//double b = Math.Round(a, 0, MidpointRounding.AwayFromZero);//?
//double b = Math.Floor(a + .5);//?
Console.WriteLine(b.ToString());
Console.ReadLine();
}
}
答案 0 :(得分:1)
尝试:
class Program
{
static void Main(string[] args)
{
decimal a = 22.58m;
decimal rounded = Math.Floor(a / 10m) * 10m;
Console.WriteLine("{0:0.00}", rounded);
Console.ReadLine();
}
}