TryParse - you should Try understanding!!!
-
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
-
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
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
-
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
-
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
That poor guy got very confused with terrible threading issues!
-
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
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]
-
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]
Exactly what I was trying to say, I guess! :thumbsup:
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925