Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am fairly new to C# coding and have started delving into lists a lot lately.
I have 2 binding lists that are somewhat related.
I have two lists that contain completely different pieces of data. Is it possible to combine these 2 lists into one list ? Is the best way to go about this to pass the 2 binding lists into a class and then combine them and return another class ?
Thanks for any and all help.

XML
listHouse= new BindingList<MyObject>();
listHouse.Add(new MyObject(1, "Outdoor"));
listHouse.Add(new MyObject(2, "Hardware"));
listHouse.Add(new MyObject(3, "Tools"));
listHouse.Add(new MyObject(4, "Books"));
listHouse.Add(new MyObject(5, "Appliances"));

listColors= new BindingList<MyOtherObject>();
listColors.Add(new MyObject(11, "Blue","UPC2222"));
listColors.Add(new MyObject(22, "Green", "UPC3432"));
listColors.Add(new MyObject(33, "Pink","UPC3444"));
listColors.Add(new MyObject(44, "Yellow","UPC7777"));







Posted

1 solution

It doesn't make any sense to combine different (and unrelated) set of data. If the 2 list you mentioned derive from same parent then you might want to create collection (of parent type). Now you can add these lists to that collection.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900