我正在尝试将“ totalSales”和“ totalCommissions”设置为货币格式,并在正确的位置加上小数点。 ($ 250,000.00)像这样
Console.WriteLine("Totals: " + totalSales + " " + totalCommissions);
答案 0 :(得分:1)
Console.WriteLine($"Totals: {totalSales:C} {totalCommissions:C}");
这是它起作用的原因:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated