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. Web Development
  3. ASP.NET
  4. how to check if string is int and return boolean

how to check if string is int and return boolean

Scheduled Pinned Locked Moved ASP.NET
questionhelptutorial
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.
  • M Offline
    M Offline
    max_dev2006 yahoo com
    wrote on last edited by
    #1

    Hello how can i check that if my string is an integer or not ? if yes then return true else false; plz help regards, max

    R J N 3 Replies Last reply
    0
    • M max_dev2006 yahoo com

      Hello how can i check that if my string is an integer or not ? if yes then return true else false; plz help regards, max

      R Offline
      R Offline
      rah_sin
      wrote on last edited by
      #2

      u can convert ur string into array of char and then can check it through method Char.IsNumber()

      rahul

      1 Reply Last reply
      0
      • M max_dev2006 yahoo com

        Hello how can i check that if my string is an integer or not ? if yes then return true else false; plz help regards, max

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #3

        int result; bool isInt = int.TryParse("123", out result);

        --- How to get answers to your questions[^]

        T 1 Reply Last reply
        0
        • J J4amieC

          int result; bool isInt = int.TryParse("123", out result);

          --- How to get answers to your questions[^]

          T Offline
          T Offline
          talk2rsoni
          wrote on last edited by
          #4

          use Try and catch block with int.parse or convet.int32() method. if any error occur then false else true.

          Rajesh soni

          1 Reply Last reply
          0
          • M max_dev2006 yahoo com

            Hello how can i check that if my string is an integer or not ? if yes then return true else false; plz help regards, max

            N Offline
            N Offline
            nlindley7
            wrote on last edited by
            #5

            Another good way: If Not IsNumeric(strString) Then bool = False Else bool = True End If Nathan Lindley .NET Aficionado

            M 1 Reply Last reply
            0
            • N nlindley7

              Another good way: If Not IsNumeric(strString) Then bool = False Else bool = True End If Nathan Lindley .NET Aficionado

              M Offline
              M Offline
              max_dev2006 yahoo com
              wrote on last edited by
              #6

              hey guys, i got one more solution . its just like if(convert.toint(str) is int) { return true; } else return false; thanks for the replies.

              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