C#C
C#3y ago
bernie2024

✅ Cant convert a list to list of a class type?

I am new to C# and am stuck on this strange issue, I cant seem to send a list to a different class, as its only accepting a list of type "Customer" (class name), how would I convert or send this information over?

Method which collects info and sends it to save method

public partial class frmCustomers : Form
    {
        List<Customer> customers = new List<Customer>();

        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmAddCustomer addCustomerForm = new frmAddCustomer();
            Customer customer = addCustomerForm.GetNewCustomer();
            if (customer != null)
            {
                CustomerDB.SaveCustomers(customer); /// This is the line giving me an error
                MessageBox.Show(customer.GetDisplayText().ToString(), "BTNAddClick2");
                CustomerListBox();
                
            }
        }


Save Method: will be posted as a comment so I dont run out of available words.
Was this page helpful?