Logynymo Logynymo - 4 months ago 60
C# Question

"Implicitly-typed variables must be initialized"

enter image description here

I have just started my learning experience with c# and this problem has been teasing me. Please help :)


You need to use int.TryParse to be safe, otherwise a wrong input would throw an error.

string userAgeInput = Console.Readline();
int userAge = 0;

if (!int.TryParse(userAgeInput, out userAge))
    Console.WriteLine("Please input a valid age!");

Now you can compare userAge.

if (userAge >= 18)