可以说我有一个List<Family>
,每个家庭都有一个List<Child>
。如何查找嵌套在多级集合中的对象
当我在代码中遇到Child
对象时,如何确定孩子是否属于任何家庭的一部分?
伪代码:
If Child not in any family
// Do something with child
更新:
实施例模型:
class Family
{
public List<Child> Children {get;set;}
// Properties
}
class Child
{
// Properties
}
实施例视图模型:
class FamilyViewModel
{
public List<Family> Families {get;set;}
public bool ChildHasFamily(Child child)
{
// Determine if child is in any family or not
}
}
你的课程是什么样的? –
在OP –
中添加信息为什么'ChildHasFamily'“返回”_void_而不是'bool'? –