如何将用户输入作为货币出现?我应该在哪里添加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();
答案 0 :(得分:2)
您可以在WriteLine上执行此操作:
Console.WriteLine(String.Format("Your transit insurance cost is {0:C}",calC));
Console.ReadLine();