using convert.ToDouble(string) when having a . in the string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TonyJ

    using convert.ToDouble(string) when having a . in the string

    Hello!

    If I have a string for example 45 .12 and I want to convert this to double
    without replacing the . with a , how is that done.

    //Tony


  • Jon Skeet [C# MVP]

    #2
    Re: using convert.ToDoubl e(string) when having a . in the string

    On Feb 8, 2:24 pm, "TonyJ" <johansson.ande rs...@telia.com wrote:
    If I have a string for example 45 .12 and I want to convert this to double
    without replacing the . with a , how is that done.
    Specify CultureInfo.Inv ariantCulture in the call to Convert as the
    IFormatProvider (or use double.Parse) - the invariant culture uses "."
    as the decimal separator.

    Jon

    Comment

    • TonyJ

      #3
      Re: using convert.ToDoubl e(string) when having a . in the string

      Hello!

      Can you give an example for a string containing 34.13
      // Tony

      "Jon Skeet [C# MVP]" <skeet@pobox.co mskrev i meddelandet
      news:5a6b8779-97a6-4e87-8c23-b08df91e3f7f@q7 7g2000hsh.googl egroups.com...
      On Feb 8, 2:24 pm, "TonyJ" <johansson.ande rs...@telia.com wrote:
      If I have a string for example 45 .12 and I want to convert this to
      double
      without replacing the . with a , how is that done.
      >
      Specify CultureInfo.Inv ariantCulture in the call to Convert as the
      IFormatProvider (or use double.Parse) - the invariant culture uses "."
      as the decimal separator.
      >
      Jon

      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: using convert.ToDoubl e(string) when having a . in the string

        On Feb 8, 2:36 pm, "TonyJ" <johansson.ande rs...@telia.com wrote:
        Can you give an example for a string containing 34.13
        double d = Convert.ToDoubl e("34.13", CultureInfo.Inv ariantCulture);

        Jon

        Comment

        Working...