Open harbaby28 opened 4 years ago
@harbaby28 Are you following a tutorial/article from docs.microsoft.com?
In case you're following a tutorial/article, please link to it.
To answer the question, the value you have for str
variable is "abcde". You're trying to split it by space, that will give an array containing "abcde" as the only element. After that, the call of int.Parse on this single element will generate an exception. You can't parse "abcde" as an integer.
The correction to the code is probably based on how you want things to work. But generally, you'll need to call TryParse on each array element after you split it, then take an appropriate action on whether TryParse returned true (success) or false (failure).
@BillWagner pinging you as I look at some older issues. I think this request has been answered accurately and can thus be closed.
System.FormatException: 'Input string was not in a correct format.' SEND HELP :(