+ 1
How do I get input of type int?
How do I get input of type int that works still if the input isn't an integer number? I tried like this but it doesn't work: https://code.sololearn.com/cOTzq7pAu1ZV/?ref=app I could put that Console.WriteLine inside the try-catch, but it doesn't work as well with multiple variables.
2 Answers
+ 2
Joel
I think Int.TryParse() will help you in this case. docs.microsoft.com has a good guide about it.
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/how-to-convert-a-string-to-a-number
+ 1
Thank you, this helped much.
(and thanks to microsofts guide)