Reputation: 952
I need to format a string in a custom number with the mask: "0000000-00.0000.0.00.0000".
I try this code:
string test = string.Format("{0:0000000-00.0000.0.00.0000}", 00014414720108190006);
The output is: "144147201081900-06,00000000000"
What is the best way to obtain a "0001441-47.2010.8.19.0006" in this example?
Thanks in advance.
Upvotes: 0
Views: 595
Reputation: 703
You need to add \ before every full stop otherwise they are interpreted as different formating.
Upvotes: 1
Reputation: 59645
You just need to escape the dots because they are usually interpreted as custom format specifiers. Use the following format string and it will work. See the MSDN for reference.
@"{0:0000000-00\.0000\.0\.00\.0000}"
Upvotes: 4