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 to convert "string" to "int"?

How to convert "string" to "int"?

Scheduled Pinned Locked Moved C#
tutorialquestion
6 Posts 5 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
    alexandr
    wrote on last edited by
    #1

    How to convert "string" to "int"? Alexandr

    M M A S 4 Replies Last reply
    0
    • A alexandr

      How to convert "string" to "int"? Alexandr

      M Offline
      M Offline
      Michael Mac
      wrote on last edited by
      #2

      I know several functions: - atof - converts to double - atoi - converts to int - _atoi64 - converts to __int64 - atol - long or function from Shell API - StrToInt - you must attach SHLWAPI.LIB library to the project I don't know if they exist in C#. Try them. Good luck :)

      M 1 Reply Last reply
      0
      • A alexandr

        How to convert "string" to "int"? Alexandr

        M Offline
        M Offline
        Mazdak
        wrote on last edited by
        #3

        Convert.ToInt32 Method or Convert.ToInt64 Method or Convert.ToInt16 Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
        Wish You Were Here-Pink Floyd-1975

        1 Reply Last reply
        0
        • M Michael Mac

          I know several functions: - atof - converts to double - atoi - converts to int - _atoi64 - converts to __int64 - atol - long or function from Shell API - StrToInt - you must attach SHLWAPI.LIB library to the project I don't know if they exist in C#. Try them. Good luck :)

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #4

          I think that's not possible. Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
          Wish You Were Here-Pink Floyd-1975

          1 Reply Last reply
          0
          • A alexandr

            How to convert "string" to "int"? Alexandr

            A Offline
            A Offline
            Ansch
            wrote on last edited by
            #5

            What about Int32.Parse("23");?? exactly the same??

            1 Reply Last reply
            0
            • A alexandr

              How to convert "string" to "int"? Alexandr

              S Offline
              S Offline
              Schnemar
              wrote on last edited by
              #6

              for any conversation i use System.Convert. Example: string str = "555"; int i = System.Convert.ToInt32(str); (also you can use ToInt16(), ToInt64() ...) See System.Convert for additional Information. Rgrds Martin

              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