我有以下课程,我需要它在父课程中有一个孩子和孩子的孩子。 我怎么能这样做?
public class Person {
public string Name { get; set; }
public int Age { get; set; }
// this person can have one or more children with Name & age properties
//this person's children can have one or more children with Name & age properties
}
谢谢
答案 0 :(得分:1)
它可以参考自己。
public class Person {
public string Name { get; set; }
public int Age { get; set; }
public List<Person> Children { get; set; }
}