+ 1
Cannot implicitly change from string to int
int x = Console.ReadLine(); Console.WriteLine("You are {0} years old today!", x); Whenever I put this code in, it tells me that I cannot implicitly change the variable from string to int, how may I work around this? I also wanted to add x++ so that it can show your age plus 1, however this isnât applicable for string var, so thatâs why I changed it. What should I do?
1 Answer
+ 3
Use the static Convert class:
Convert.ToInt32(Console.ReadLine());