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. String to Int

String to Int

Scheduled Pinned Locked Moved C#
question
5 Posts 4 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.
  • B Offline
    B Offline
    Blekk
    wrote on last edited by
    #1

    Hi, I know that to convert an int to a string you use: myInt.toString(); But, I want to convert a string to int, what is the function for this? Thanks.

    S S J 3 Replies Last reply
    0
    • B Blekk

      Hi, I know that to convert an int to a string you use: myInt.toString(); But, I want to convert a string to int, what is the function for this? Thanks.

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

      In .NET 2.0 use Int32.TryParse, otherwise Int32.Parse.


      "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

      B 1 Reply Last reply
      0
      • S Stefan Troschuetz

        In .NET 2.0 use Int32.TryParse, otherwise Int32.Parse.


        "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

        B Offline
        B Offline
        Blekk
        wrote on last edited by
        #3

        Thanks mate, a great help

        1 Reply Last reply
        0
        • B Blekk

          Hi, I know that to convert an int to a string you use: myInt.toString(); But, I want to convert a string to int, what is the function for this? Thanks.

          S Offline
          S Offline
          Syed Shahid Hussain
          wrote on last edited by
          #4

          There is also a method like Convert(variable,CType) :laugh: Good Luck

          Syed Shahid Hussain

          1 Reply Last reply
          0
          • B Blekk

            Hi, I know that to convert an int to a string you use: myInt.toString(); But, I want to convert a string to int, what is the function for this? Thanks.

            J Offline
            J Offline
            Jon Sagara
            wrote on last edited by
            #5

            Just FYI, there is also a method called Convert.ToInt32(). Either method will work fine.

            Jon Sagara When I grow up, I'm changing my name to Joe Kickass! My Site | My Blog | My Articles

            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