// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.Linq; namespace E { public class A { public int AID { get; set; } public string AS { get; set; } public List B { get; set; } public List C { get; set; } } public class B { public int BID { get; set; } public string BS { get; set; } } public class C { public int CID { get; set; } public string CS { get; set; } } public class Program { public static void Main(string[] args) { List alst = new List { new A { AID=1, AS="A1", B=new List { new B { BID=1, BS="B1" } }, C=new List { new C { CID=2, CS="C2" } } }, new A { AID=2, AS="A2", B=new List { new B { BID=2, BS="B2" } }, C=new List { new C { CID=1, CS="C1" } } } }; foreach (A a in alst) { Console.WriteLine("{0} {1} {2}", a.AS, a.B[0].BS, a.C[0].CS); } } } }