What’s the difference between ToString(“D2”) .ToString(“00”)

It is an interesting question. The only difference I have found so far is:

format “D2” accepts only integer type values. Where as format “00” would work with floats/doubles as well.

Format D – MSDN

Supported by: Integral types only.

Consider the following three lines:

double d = 23.05123d;
int i = 3;
Console.Write(i.ToString("D2"));
Console.Write(d.ToString("00"));
Console.Write(d.ToString("D2")); //this will result in exception: 
                                 //Format specifier was invalid.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)