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. How do I convert string to double

How do I convert string to double

Scheduled Pinned Locked Moved C#
csharphelpquestion
8 Posts 6 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.
  • A Offline
    A Offline
    acodman
    wrote on last edited by
    #1

    Hi all, C# as my language of choice. I have a web page that accepts input into a text box and in the button click the value should be converted to double for computation to take place. I mean: a = Convert.Todouble(textbox1.text); I keep getting this error: "You can't implicitly conver string to double" please show me the way out! thanks in advance

    M S C B 5 Replies Last reply
    0
    • A acodman

      Hi all, C# as my language of choice. I have a web page that accepts input into a text box and in the button click the value should be converted to double for computation to take place. I mean: a = Convert.Todouble(textbox1.text); I keep getting this error: "You can't implicitly conver string to double" please show me the way out! thanks in advance

      M Offline
      M Offline
      mihksoft
      wrote on last edited by
      #2

      double.Parse(string s);

      A 1 Reply Last reply
      0
      • A acodman

        Hi all, C# as my language of choice. I have a web page that accepts input into a text box and in the button click the value should be converted to double for computation to take place. I mean: a = Convert.Todouble(textbox1.text); I keep getting this error: "You can't implicitly conver string to double" please show me the way out! thanks in advance

        S Offline
        S Offline
        Stefan Troschuetz
        wrote on last edited by
        #3

        Hmm. the above should work because the ToDouble has an overload that takes a String object. Are you sure the error occurs at this line? Alternatively you could try using double.TryParse. Personally, I prefer TryParse over ToDouble anyway.


        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

        www.troschuetz.de

        1 Reply Last reply
        0
        • M mihksoft

          double.Parse(string s);

          A Offline
          A Offline
          acodman
          wrote on last edited by
          #4

          thanks

          1 Reply Last reply
          0
          • A acodman

            Hi all, C# as my language of choice. I have a web page that accepts input into a text box and in the button click the value should be converted to double for computation to take place. I mean: a = Convert.Todouble(textbox1.text); I keep getting this error: "You can't implicitly conver string to double" please show me the way out! thanks in advance

            C Offline
            C Offline
            cppShooter
            wrote on last edited by
            #5

            this value "a" is a string type?

            1 Reply Last reply
            0
            • A acodman

              Hi all, C# as my language of choice. I have a web page that accepts input into a text box and in the button click the value should be converted to double for computation to take place. I mean: a = Convert.Todouble(textbox1.text); I keep getting this error: "You can't implicitly conver string to double" please show me the way out! thanks in advance

              C Offline
              C Offline
              cppShooter
              wrote on last edited by
              #6

              this value "a" is string type?

              1 Reply Last reply
              0
              • A acodman

                Hi all, C# as my language of choice. I have a web page that accepts input into a text box and in the button click the value should be converted to double for computation to take place. I mean: a = Convert.Todouble(textbox1.text); I keep getting this error: "You can't implicitly conver string to double" please show me the way out! thanks in advance

                B Offline
                B Offline
                blackjack2150
                wrote on last edited by
                #7

                Also, pay attentionto the number format used by the local machine. You may get errors if the decimal separator used by the local machine is "," and the user inputs "." as a separator or viceversa. You can see it under Local Settings in Control Panel.

                R 1 Reply Last reply
                0
                • B blackjack2150

                  Also, pay attentionto the number format used by the local machine. You may get errors if the decimal separator used by the local machine is "," and the user inputs "." as a separator or viceversa. You can see it under Local Settings in Control Panel.

                  R Offline
                  R Offline
                  Russell Jones
                  wrote on last edited by
                  #8

                  for that you could use the overload to try parse that takes an IFormatter input aswell. RUssell

                  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