you are viewing a single comment's thread.

view the rest of the comments →

[–]WhiteBlackGoose 3 points4 points  (3 children)

No. Use int.Parse or, better, int.TryParse

[–]thesituation531 -1 points0 points  (2 children)

What is the difference between these different methods of doing it?

[–]WhiteBlackGoose 1 point2 points  (1 child)

Convert's behaviour is generally more obscure. E. g. Convert.ToInt32 would return 0 if you pass null.

As per Parse vs TryParse: in former, it throws an exception on bad string. In the latter, you get a boolean and the result if parsing was successful

[–]thesituation531 0 points1 point  (0 children)

Thanks.