class objA
{
public Rectangle area;
}
class objB
{
public Point somepoint;
}
List<objA> listA;
List<objB> listB;
现在,我想在任何地方获取 listA 和 listB 中的元素objA.area.contains(objB.point)
这应该可以解决问题:
result = listA.Select(a=>
new{
Rectangle = a,
Points =listB.Where(b=>a.Contains(b))
});
您可能会考虑进行from from where
样式查询,也称为非 equi 连接:
from rect in listA
from point in listB
where rect.Area.Contains(point.SomePoint)
select new { rect, point }