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. Other Discussions
  3. The Weird and The Wonderful
  4. TryParse - you should Try understanding!!!

TryParse - you should Try understanding!!!

Scheduled Pinned Locked Moved The Weird and The Wonderful
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.
  • V Offline
    V Offline
    VallarasuS
    wrote on last edited by
    #1

    Came across this piece of code in a source library ;P

            string sParam1 = \_param1; 
            string sParam2 = \_param2;
            int iOut1 = -1, iOut2 = -1;
            /\* above added to mark their type \*/
            
            if (Int32.TryParse(sParam1, out iOut1) && Int32.TryParse(sParam2, out iOut2))
            {
                Int32.TryParse(sParam1, out iOut1);
                Int32.TryParse(sParam2, out iOut2);
            }
    

    Me and my colleague ended up :laugh: !! believe me or not this piece is written recently by the one known as the lead!! ;P

    M L B 3 Replies Last reply
    0
    • V VallarasuS

      Came across this piece of code in a source library ;P

              string sParam1 = \_param1; 
              string sParam2 = \_param2;
              int iOut1 = -1, iOut2 = -1;
              /\* above added to mark their type \*/
              
              if (Int32.TryParse(sParam1, out iOut1) && Int32.TryParse(sParam2, out iOut2))
              {
                  Int32.TryParse(sParam1, out iOut1);
                  Int32.TryParse(sParam2, out iOut2);
              }
      

      Me and my colleague ended up :laugh: !! believe me or not this piece is written recently by the one known as the lead!! ;P

      M Offline
      M Offline
      Manfred Rudolf Bihy
      wrote on last edited by
      #2

      Nothing unusual to see here. He's just checking twice to make sure it's really parsable. :laugh: It's like when I'm just about to exit my flat and close the door behind me, I check if I have the keys with me. It doesn't really matter that I already checked that before embarking on my way to the door. I just need to make sure. You know? Like really, really sure. Sometimes checking only once is just not enough. :-D

      "With sufficient thrust, pigs fly just fine."

      Ross Callon, The Twelve Networking Truths, RFC1925

      C 1 Reply Last reply
      0
      • V VallarasuS

        Came across this piece of code in a source library ;P

                string sParam1 = \_param1; 
                string sParam2 = \_param2;
                int iOut1 = -1, iOut2 = -1;
                /\* above added to mark their type \*/
                
                if (Int32.TryParse(sParam1, out iOut1) && Int32.TryParse(sParam2, out iOut2))
                {
                    Int32.TryParse(sParam1, out iOut1);
                    Int32.TryParse(sParam2, out iOut2);
                }
        

        Me and my colleague ended up :laugh: !! believe me or not this piece is written recently by the one known as the lead!! ;P

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        The person who wrote this code is probably suffering from OCD[^]. :)

        1 Reply Last reply
        0
        • V VallarasuS

          Came across this piece of code in a source library ;P

                  string sParam1 = \_param1; 
                  string sParam2 = \_param2;
                  int iOut1 = -1, iOut2 = -1;
                  /\* above added to mark their type \*/
                  
                  if (Int32.TryParse(sParam1, out iOut1) && Int32.TryParse(sParam2, out iOut2))
                  {
                      Int32.TryParse(sParam1, out iOut1);
                      Int32.TryParse(sParam2, out iOut2);
                  }
          

          Me and my colleague ended up :laugh: !! believe me or not this piece is written recently by the one known as the lead!! ;P

          B Offline
          B Offline
          Bernhard Hiller
          wrote on last edited by
          #4

          That poor guy got very confused with terrible threading issues!

          1 Reply Last reply
          0
          • M Manfred Rudolf Bihy

            Nothing unusual to see here. He's just checking twice to make sure it's really parsable. :laugh: It's like when I'm just about to exit my flat and close the door behind me, I check if I have the keys with me. It doesn't really matter that I already checked that before embarking on my way to the door. I just need to make sure. You know? Like really, really sure. Sometimes checking only once is just not enough. :-D

            "With sufficient thrust, pigs fly just fine."

            Ross Callon, The Twelve Networking Truths, RFC1925

            C Offline
            C Offline
            Chris Meech
            wrote on last edited by
            #5

            Why do you think it's called "double-checking"? :doh:

            Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

            M 1 Reply Last reply
            0
            • C Chris Meech

              Why do you think it's called "double-checking"? :doh:

              Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

              M Offline
              M Offline
              Manfred Rudolf Bihy
              wrote on last edited by
              #6

              Exactly what I was trying to say, I guess! :thumbsup:

              "With sufficient thrust, pigs fly just fine."

              Ross Callon, The Twelve Networking Truths, RFC1925

              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