Main Site Documentation

Tostring format question


#1

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:

nds.ToString("d2");

just crashed with an error!


#2

“d” is not a valid format.

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

http://msdn.microsoft.com/en-us/library/cc506840.aspx


#3

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