I'm trying to create an ArrayList with cars I've created using a constructor class and then afterwards use a foreach loops to then print the model name of each cars.
I've created the car objects as following
Car car1 = new Car("Audi e-tron", "Black", 2021);
Car car2 = new Car("Audi RS7", "Black", 2021);
Car car3 = new Car("Audi A5", "Black", 2021);
I created the ArrayList and attempted to begin adding the car objects to the ArrayList
ArrayList carList = new ArrayList();
carList.Add(car1);
carList.Add(car2);
carList.Add(car3);
I tested to see if the code was working properly up to this point and checked if the ArrayList has populated
Console.WriteLine("car list: {0}", carList[0]);
but that returns
ArrayListPractice.MainClass+Car
How can I add objects from the constructor to the ArrayList and return a parameter of the object? Thank you!