String format options for int in .NET.

I want to convert int to string, but if it is one digit, I want to add leading 0

Is this one of the built-in formatting options? or do i need to do it manually?

+5
source share
1 answer

This can be achieved using regular string formats:

3.ToString("00");

As a result, the string "03" appears.

See custom number format strings on MSDN and their outputs .

+10
source

All Articles