Searching through Objects with multiple levels of Generic List Objects

Aug 13 2007 5:55 PM
 

Take a look at the following code.  You will notice that Cases contains a List<Bottles>.  Each Bottles Object contains a List<MyLabels>.  In my code I am handed a List<Cases>.  Now I need boil down the List<Cases> in to a List<MyLabels> I received!

 

How do I do this? 

 

Public List<MyLabels> getListOfLabels(List<Cases> cases)

{

\\A bunch of foreach(s)?

 

}

 

 

 

public class MyLabels

{

private string brand;

public string Brand

{

get { return brand; }

set { brand = value; }

}

private int number;

public int Number

{

get { return number; }

set { number = value; }

}

public MyLabels(string Brand, int Number)

{

this.brand = Brand;

this.number = Number;

}

}

 

public class Bottles

{

private List<MyLabels> listoflabels = new List<MyLabels>();

public List<MyLabels> ListOfLabels

{

get { return listoflabels; }

set { listoflabels = value; }

}

public Bottles(List<MyLabels> ListOfLabels)

{

this.listoflabels = ListOfLabels;

}

}

 

public class Cases

{

private List<Bottles> bottlesincase = new List<Bottles>();

public List<Bottles> BottlesInCase

{

get { return bottlesincase; }

set { bottlesincase = value; }

}

public Cases(List<Bottles> BottlesInCase)

{

this.bottlesincase = BottlesInCase;

}

}

 

Thanks

 

Bryan


Answers (2)