문제

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
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top