I'm getting this exception
FormatException was unhandled, input string was not in a correct format.
at the following statement
int amnt = int.Parse(Console.ReadLine());
what should I do to solve it?
I would suggest the following:
int parsedInt = 0;
if (int.TryParse(Console.ReadLine(), out parsedInt))
{
//do success work
}
else
{
//do failed work
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.