tags:

views:

50

answers:

2

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.

+4  A: 

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}"
Daniel Brückner
Works fine! Thanks a lot!
reikara
+1  A: 

You need to add \ before every full stop otherwise they are interpreted as different formating.

Sir Graystar