Custom numeric format strings

2023-11-14

string Multiplier="Multiplier:{0:#,}";
Console.WriteLine (string.Format (Multiplier, 1000000));
string LiteralChar = "LiteralChar={0:\\#000}";
Console.WriteLine (string.Format (LiteralChar, 50));
string LiteralString = "LiteralString={0:000'...'}";
Console.WriteLine (string.Format (LiteralString, 50));
string SectionSeparator="SectionSeparator={0:#;(#);zero}";
Console.WriteLine (string.Format (SectionSeparator, -15));
string Literal="Literal={0:$0 . $35 . 20c00c}";
Console.WriteLine (string.Format (Literal, 35.2));

结果:

Multiplier:1000
LiteralChar=#050
LiteralString=050...
SectionSeparator=(15)
Literal=$35 . $35  22c00c 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Custom numeric format strings 的相关文章

随机推荐