Strange string.Format behavior
I've a double variable called totalCost and it's value is 1025. The result
of calling a simple string.Format is the following:
?string.Format("{0}",totalCost)
"1,025"
Since my thousand separator is the coma while the decimal separator is the
dot.
The weird part is the following:
?string.Format("{0:0.0}",totalCost)
"1,0"
Doesn't it should be 1025.0 (or 1,025.0)?
It seems that it converts the double in a string (giving "1.025") and then
re-parse it without using my separator settings (interpreting it as
1-and-25-thousandths) and finally it formats the converted value.
No comments:
Post a Comment