Tuesday, December 06, 2005 10:20 PM bart

int.Parse weird behavior

What a brainteaser this was. The last couple of days/hours I was following this thread on MSDN about weird behavior of int.Parse:

int.Parse("0") //throws FormatException

Basically, the problem was the sPositiveSign value under HKEY_CURRENT_USER\Control Panel\International being set to 0, which means the positive sign is '0'. Thus, while parsing the "positive sign 0" is being cut off and then the rest of the string ("") is parsed as a number, which doesn't work of course. This also explains why int.Parse("00") wasn't a problem. Although you can't set the positive sign to '0' through the Control Panel, it's still possible to do it through the registry, causing problems. No idea how the computer of the user in the post ended up with this wrong setting...

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Filed under:


# Zabek Answers

Wednesday, December 10, 2014 10:20 AM by Zabek Answers

Pingback from  Zabek Answers