Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a Collection of Collections possible and/or the best way? C# .Net 3.5

I have created a class for a dashboard item which will hold information such as placement on the dashboard, description, etc. I am currently using a pair of Collections to hold those dashboard items contained in the "library" and those items showing on the dashboard itself. I have been asked to make this dashboard multi-tab, and my first inclination was to make a new Collection for each tab. For this I would want some type of array or collection which could have many of these dashboard item collections added to it as more tabs are added to the dashboard.

Is this possible, and if so, could I get a little code snip for the declaration of such a collection? I have considered using a single collection with a variable to show which tab the item will be shown in... However, the display and routines to manage dashboard item movement between screen and library currently need those individual collections.

Edit: Thank you for your answers. While I do find them all interesting I believe I am going to go with James solution and will be marking it as the accepted answer.

like image 570
Totty Avatar asked Oct 27 '08 14:10

Totty


1 Answers

List< List<Placement>> ListofListOfPlacements = new List< List<Placement>> ();

List<Placement> dashboard1 = new List<Placement>();
List<Placement> dashboard2 = new List<Placement>();
List<Placement> dashboard3 = new List<Placement>();
List<Placement> dashboard4 = new List<Placement>();

ListofListOfPlacements.Add(dashboard1);
ListofListOfPlacements.Add(dashboard2);
ListofListOfPlacements.Add(dashboard3);
ListofListOfPlacements.Add(dashboard4);
like image 89
James Curran Avatar answered Nov 14 '22 23:11

James Curran