PDA

View Full Version : XDoc elements of type double and InvariantCulture



dani
07-03-2008, 10:36 AM
Hello,
First of I want to thanks you for your work. I really like dream!!

Now, my system has a CultureInfo set to Spain, and if I want to add a double element in a XDoc and use
elemXml.Elem("price", this.Price);
i get the number in a non xml-standart format, with a "," decimal separator.

It works with
elemXml.Elem("price",this.Price.ToString("F", CultureInfo.InvariantCulture));
My suggestion is that in the same way you have overloads for
public XDoc Value(bool value) {
return Value(value ? "true" : "false");
}

if you can add some other like
public XDoc Value(double value) {
return Value(value.ToString("F", CultureInfo.InvariantCulture));
}
or something similar.
Thanks.

SteveB
07-07-2008, 07:41 PM
Thanks for the kind words!

Ah, I'm not sure I agree. It's hard to predict what format people want to use. How about you set the CultureInfo object on your processing thread instead? This will ensure that your application produces consistent output, regardless of locale. Alos, it will not prevent others from using the locale specific formatting if they so desire.

dani
07-08-2008, 04:02 PM
You are right, that is a better solution.
Thanks.