I have a small array of movies which shows various information about each movie, including the start time and the running time. I want to add new movies to the listings through user input (by filling the details into textboxes and pressing a button), and I am able to add the name, genre and age rating, but I am struggling to add the times.
My array code is as follows:
List<Movies> movies = new List<Movies>();
InitializeArrayList();
public void InitializeArrayList()
{
movies.Add(new Movies("The Avengers", "Action", "PG-13", 18, 05, 3, 15));
movies.Add(new Movies("Inside Out", "Adventure", "PG", 16, 25, 1, 52));
movies.Add(new Movies("Jurassic World", "Action/Adventure", "PG-13", 20, 10, 2, 04));
}
So the time is read in the format of two ints: one for the hour and one for the minutes. It prints in the following format:
18:05
The following is my code snippet for adding:
private void button6_Click(object sender, EventArgs e)
{
movies.Add(new Movies(textBox1.Text, textBox2.Text, textBox3.Text, Convert.ToInt32(textBox4.Text), Convert.ToInt32(textBox4.Text), Convert.ToInt32(textBox5.Text), Convert.ToInt32(textBox5.Text),
this.DisplayData();
}
In this part, DisplayData() prints all the information into the textboxes to view the array. I know this is not correct, but I'm not sure how to fix it. Does anyone know how I can get it to read two integers from the textbox and print it out?