0

我正在研究金钱,但我不知道该怎么做。那么,我该如何完善这些示例 - 22.3220.00156.32150.0023556.0023550.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();
        }
    }
4

1 回答 1

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();
    }
}
于 2013-02-22T13:07:38.023 回答