0

User Input

I racked my brain out for many many tries. What is the solution? Many thanks! namespace SoloLearn { class Program { static void Main(string[] args) { int age = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("You are {0} years old", age); } }

28th May 2020, 2:20 PM
Cindy
Cindy  - avatar
5 odpowiedzi
+ 4
If is working right ,maybe you forgot to close opening curly bracket? Or what is the error you are getting?
28th May 2020, 2:27 PM
Abhay
Abhay - avatar
+ 1
Did you delete all the imports above the namespace-line? This would break the code as well...
28th May 2020, 3:37 PM
Sandra Meyer
Sandra Meyer - avatar
+ 1
It works fine if you: 1. Add the imports. 2. Add a last closing curly brace at the end of your code. See https://code.sololearn.com/cvv49CE64Luq/?ref=app
28th May 2020, 3:51 PM
Sandra Meyer
Sandra Meyer - avatar
+ 1
Finally: Do not copy & paste!
28th May 2020, 3:51 PM
Sandra Meyer
Sandra Meyer - avatar
0
i hust cut and pasted the text from the C# Sololearn tutorial. i believe the syntax and punctuation is cottect. Do you input the string name in my case twenty one or the int age 21 into the coding text? i tried several times using strings and numbers.
28th May 2020, 3:40 PM
Cindy
Cindy  - avatar