© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
11 replies
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();
                
            }
        }
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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

cannot convert from 'TypeA' to 'TypeB' with generics
C#CC# / help
2y ago
❔ How to add a list of type of another class in c#?
C#CC# / help
3y ago
cant convert type (int, int) to Vector2
C#CC# / help
2y ago
✅ Convert List to IList
C#CC# / help
3y ago