string str = "199"
int.Parse(str)
Convert.ToInt32(str)
int.Parse(str)
- This method converts the string to integer.
- If string variable 'str' is null, then it will throw ArgumentNullException.
- If string 'str' has out of integer ranges, then it will throw OverflowException.
- If string 'str' is other than integer value, then it will throw FormatException.
Convert.ToInt32(str)
- This method converts the string to integer.
- If string str is null, then it will return 0 rather than throw ArgumentNullException.
- If string str represents out of integer ranges, then it will throw OverflowException.
- If string str is other than integer value, then it will throw FormatException.