+ Reply to Thread
Results 1 to 3 of 3

Thread: XDoc elements of type double and InvariantCulture

  1. #1

    Default XDoc elements of type double and InvariantCulture

    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.
    Last edited by dani; 07-03-2008 at 10:53 AM.

  2. #2
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    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.
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

  3. #3

    Default

    You are right, that is a better solution.
    Thanks.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts