?string.Format("{0:D3}", 10/2)
{"Format specifier was invalid."}
_HResult: -2146233033
_message: "Format specifier was invalid."
I need to represent a double like a integer of 3 digits. Say “5.2” should be represented as “005” and say “5.9” should be better as “006” but is OK even if it is “005”.
Does the Framework not support representing a Double like a Integer?
Found an alternative solution to use
?string.Format("{0:000}", 5.9)instead.I can’t use “D” or “d” specifier because it is “Supported by: Integral types only.” (Standard Numeric Format Strings – MSDN)