C# 6 how to format double using interpolated string?

后端 未结 2 1241
无人及你
无人及你 2020-12-29 01:01

I have used interpolated strings for messages containing string variables like $"{EmployeeName}, {Department}". Now I want to use an inte

相关标签:
2条回答
  • 2020-12-29 01:10

    You can specify a format string after an expression with a colon (:):

    var aNumberAsString = $"{aDoubleValue:0.####}";
    
    0 讨论(0)
  • 2020-12-29 01:21

    A colon after the variable specifies a format,

    Console.Write($"{aDoubleValue:0.####}");
    
    0 讨论(0)
提交回复
热议问题