Logo

Programming-Idioms

History of Idiom 156 > diff from v14 to v15

Edit summary for version 15 by bigwavedave:
New Csharp implementation by user [bigwavedave]

Version 14

2019-09-28, 22:44:15

Version 15

2019-10-07, 23:23:50

Idiom #156 Format integer with zero-padding

Assign to string s the value of integer i in 3 decimal digits. Pad with zeros if i < 100. Keep all digits if i1000.

Idiom #156 Format integer with zero-padding

Assign to string s the value of integer i in 3 decimal digits. Pad with zeros if i < 100. Keep all digits if i1000.

Extra Keywords
pad leading fixed width
Extra Keywords
pad leading fixed width
Code
string s = string.Format("{0:000}",i);