Not able to cast string to int. Error msg: Input string was not in a correct format

I think the line “Input string was not in a correct format” explains it all. In the line

 int i = Convert.ToInt32(str);

str might be containing alphabetic characters. Take a look at it while debugging, what does it contain?

Leave a Comment