Reputation: 10540
I want to convert an int to a string but if it is a single digit I want to add a leading 0
Is that one of the built in format options? or do I have to do it manually?
Upvotes: 5
Views: 1007
Reputation: 498914
This can be achieved with normal string formats:
3.ToString("00");
Will result in the string "03".
See custom numeric format strings on MSDN and their outputs.
Upvotes: 10