Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Converting a string to a double

Converting a string to a double

Scheduled Pinned Locked Moved C#
questionhelptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hellamasta
    wrote on last edited by
    #1

    Hi everybody!!! I have a TextBox in which user write a float number. Decimal separator is the dot ".". I have to save the Text of the textbox into a numeric variable... i chosen a double variable. But when I call Convert.ToDouble(myString) method and myString is, for example 1.5, the number written in the variable is 15. How can I solve this problem? thank you

    G 1 Reply Last reply
    0
    • H hellamasta

      Hi everybody!!! I have a TextBox in which user write a float number. Decimal separator is the dot ".". I have to save the Text of the textbox into a numeric variable... i chosen a double variable. But when I call Convert.ToDouble(myString) method and myString is, for example 1.5, the number written in the variable is 15. How can I solve this problem? thank you

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      You have to specify the correct CultureInfo or NumberFormatInfo object when you convert the number. Now you are using the default culture, and that obviously uses a comma for decimal separator as it ignores the period. --- b { font-weight: normal; }

      H 2 Replies Last reply
      0
      • G Guffa

        You have to specify the correct CultureInfo or NumberFormatInfo object when you convert the number. Now you are using the default culture, and that obviously uses a comma for decimal separator as it ignores the period. --- b { font-weight: normal; }

        H Offline
        H Offline
        hellamasta
        wrote on last edited by
        #3

        ok, but with the comma I had the same problem...now I try with the culture info thankyou

        1 Reply Last reply
        0
        • G Guffa

          You have to specify the correct CultureInfo or NumberFormatInfo object when you convert the number. Now you are using the default culture, and that obviously uses a comma for decimal separator as it ignores the period. --- b { font-weight: normal; }

          H Offline
          H Offline
          hellamasta
          wrote on last edited by
          #4

          I found the problem, thanks for your help Alessio

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups