In C# I have an integer value which need to be convereted to string but it needs to add zeros before:
For Example:
int i = 1;
When
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+)
i.ToString().PadLeft(4, '0')
i.ToString("0000");
i.ToString("D4");
$"{i:0000}";