日期:2014-05-18 浏览次数:20448 次
class Program { static void Main(string[] args) { List<Person> list = new List<Person>(); Get(list, 1); Console.ReadLine(); } static void Get(List<Person> list, int i) { if (i == 3) return; if (list == null) list = new List<Person>(); Person p = new Person(); p.ID = i; list.Add(p); Get(p.list, ++i); } } class Person { public int ID { get; set; } public List<Person> list { get; set; } }
class Program { static void Main(string[] args) { List<Person> list = new List<Person>(); Get(list, 1); Console.ReadLine(); } static void Get(List<Person> list, int i) { if (i == 3) return; Person p = new Person(); p.ID = i; list.Add(p); p.list= new List<Person>(); Get(p.list, ++i); } } class Person { public int ID { get; set; } public List<Person> list { get; set; } }