格式化字符串中的数字
你可以使用冒号和标准数字格式语法来控制数字的格式。
var decimalValue = 120.5;
var asCurrency = $"It costs {decimalValue:C}";
// String value is "It costs $120.50" (depending on your local currency settings)
var withThreeDecimalPlaces = $"Exactly {decimalValue:F3}";
// String value is "Exactly 120.500"
var integerValue = 57;
var prefixedIfNecessary = $"{integerValue:D5}";
// String value is "00057"