Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

add leading zeroes in c#

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+)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #leading #zeroes
ADD COMMENT
Topic
Name
8+5 =