How do I add "0" padding to a string so that my string length is always 4?
Example
If input "1", 3 padding is added = 0001
If input "25", 2 padding is added = 0025
If input "301", 1 padding is added = 0301
If input "4501", 0 padding is added = 4501
"12345".PadLeft(4,'0')
is still "12345" - it won't truncate it. This doesn't detract from this answer by the way since it meets all the specs (there's something strangely satisfying about having an answer you upvoted chosen as the accepted one (though not as satisfying as having one of your own accepted of course), sort of like your son getting into the best school), just thought I'd mention it in case it reared its ugly head sometime in the future. Cripes, I hope those parentheses are balanced :-) – Kinematograph