tags:

views:

64

answers:

1

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?

+6  A: 

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.

Oded