将输出转换为货币

时间:2016-04-11 17:13:42

标签: c# currency

如何将用户输入作为货币出现?我应该在哪里添加string.Format();代码?

        double transitInsA = new double();
        transitInsA = insuranceRate/100;

        double transitInsB = new double();
        transitInsB = transitInsA*insuranceValue;

        double calA = new double();
        calA = 3.6/100;
        double calB = new double();
        calB = calA*transitInsB;
        double calC = new double();
        calC = calB + transitInsB;

        Console.WriteLine("Your transit insurance cost is" + calC);
        Console.ReadLine();

1 个答案:

答案 0 :(得分:2)

您可以在WriteLine上执行此操作:

  Console.WriteLine(String.Format("Your transit insurance cost is {0:C}",calC));
  Console.ReadLine();