I am trying to duplicate a text report that was written in Icon in 开发者_StackOverflowC#. The report has:
Blah Blah........ $ 10,938.09
Blah Blah........ $ 3.88
Blah Blah........ $ 102,398.11
I am able to use multiple formatting calls to achieve this result with out issue, for example:
Console.WriteLine(string.Format("Blah Blah.....${0,10}", number.ToString("#,##0.00")));
but I would think there is a way to do it with just one call to string.Format(). Any idea how to insert leading spaces in a currency format?
You do it like so:
Console.WriteLine(string.Format("Blah Blah.....${0,10:#,##0.00}", number));
Update:
This is the relevant part of the documentation.
精彩评论