📜  在 c# 代码示例中添加前导零

📅  最后修改于: 2022-03-11 14:49:14.155000             🧑  作者: Mango

代码示例1
i.ToString().PadLeft(4, '0') - okay, but doesn't work for negative numbers
i.ToString("0000"); - explicit form
i.ToString("D4"); - short form format specifier
$"{i:0000}"; - string interpolation (C# 6.0+)