Main Site Documentation

Tostring format question


I have numbers (strings) 0-99, but want 00, 01, 02…22,33, 99, etc. basically everything is two digits—one digit numbers preceded by a zero

I tried:


just crashed with an error!


“d” is not a valid format.

Here’s a link to MSDN NETMF documentation showcasing valid formats:


Since none of these did the trick, I did:

 string StrSec = "00" + seconds.ToString();
     return (" " + StrSec.Substring(StrSec.Length - 2));

was just looking for something simpler