I have a list of items ('sections') which has a getter and a setter. Each one of these 'sections' has a list of 'items'. I'd like to provide a yield return property to expose an 'Items' property as an IEnumerable on the containing class. I just can't get the syntax quite right. Do I need another loop in here or will that iterate too many times?
public virtual IList<ISection> Sections{ get; set; }
public virtual IEnumerable<IItem> Sections {
get{
foreach (var sect in Sections) {
// will this iterate too many times if I add an additional loop?
yield return sect.Items
}
}
}