c# - Why does decimal min value not convert to a string? -
the following console app crashes:
decimal dec = decimal.minvalue; string str = string.format("{0:d}", dec); console.writeline(str); the error is:
format specifier invalid. given i'm formatting decimal decimal, wrong this?
from the documentation:
this format supported integral types.
decimal isn't integral type.
the fact format type called "decimal" unfortunate, basically. it's because formats integers in base 10, it's not directly related decimal type.
i suspect want f, g or n (or possibly else, based on actual requirements, aren't clear).
Comments
Post a Comment