I am playing around with windows forms and was wondering if there was a way to create a new object based on user input. Basically I want to be able to create a new object with what ever the user puts into the make textbox, add it to a List<Car>() and then display the model in the listbox. Just need to know if there is a way to make an object without knowing the name (such as Car xxx = new Car(make, model, year)) or knowing how many objects will be created and be able to pass in parameters. Below is the code for the simple car class and a screen capture of the program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CreateNewObjectsTest
{
class Car
{
private string make;
private string model;
private int year;
public Car(string make, string model, int year)
{
this.make = make;
this.model = model;
this.year = year;
}
public string GetModel()
{
return model;
}
}
}