开发者

Custom number formatting

开发者 https://www.devze.com 2023-01-02 08:53 出处:网络
I need to format a string in a custom number with the mask: \"0000000-00.0000.0.00.0000\". I try this code:

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 o开发者_如何学Pythonutput is: "144147201081900-06,00000000000"

What is the best way to obtain a "0001441-47.2010.8.19.0006" in this example?

Thanks in advance.


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}"


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

0

精彩评论

暂无评论...
验证码 换一张
取 消