Loop through collections
- by ScG
I have two classes
class A
{
public string something { get; set; }
public IList<B> b= new List<B>();
}
class B
{
public string else { get; set; }
public string elseelse { get; set; }
}
I have populated an object of class A called obj. How can I loop through this object and print values. Do I have to use two foreach's like the one show here or is there a better way?
foreach (var z in obj)
{
// print z.something;
foreach (var x in z.b)
{
// print x.elseelse;
}
}