I’m new to coding and I’m trying to figure how to use user input. Right now my code is not working. I want to have the user input added to the movie list.
//Creating the welcome screen
string Titlescreen = "Welcome to Movie list \n\t Please choose an option \n\t 1. Display Movie list \n\t 2. Add Movies to the List\n\t 3. Show movies I've watched\n\t";
//Creating movie list
var Movies = new List<string>();
// Displaying Welcome screen and gather user input
Console.WriteLine(Titlescreen);
string userChoice;
userChoice = Console.ReadLine();
numberChoice = Convert.ToInt32(userChoice);
if(numberChoice == 1)
{
foreach(string movie in Movies)
{
Console.WriteLine(movie);
}
}
else if(numberChoice == 2)
{
var userChoice = Console.ReadLine();
Movies.Add(userChoice);
}
New contributor
Dee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3