What am i doing wrong? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

What am i doing wrong?

static void Main(string[] args) { string myName; int myAge = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("what is your name and age ?"); myName = Console.ReadLine(); Console.WriteLine("Hello ! {0}", myName); Console.WriteLine("and {0}", myAge); }

15th Apr 2018, 2:39 PM
Prateek Shrivastav
Prateek Shrivastav - avatar
3 Respuestas
+ 8
The code is not consistent as the variables are declare and initialize in 2 different ways. Besides, I guess the age input should be followed after the question prompt, not before. P/S: If possible please try to embed the code in Code Playground so others can read and understand your code better. 😉
15th Apr 2018, 3:34 PM
Zephyr Koo
Zephyr Koo - avatar
+ 4
I tried The code, it could be improved but it works. What problem did you have?
15th Apr 2018, 4:10 PM
Paul
Paul - avatar
+ 2
when trying to take an integer from input, you should use int.Parse() not Convert.ToInt32(), just some advice.
15th Apr 2018, 2:57 PM
hinanawi
hinanawi - avatar