I am absolute beginner with Linq. I have a for loop that I want to convert to Linq statement. This loop is basically performing a hit test on rectangles which are hitting an edge. It is excluding a rectangle.
private List<Rectangle> GetTouchingRects(List<Rectangle> rects, Edge edgeToCheck, Rectangle exclude)
{
List<Rectangle> hittingRects = new List<Rectangle>();
foreach (Rectangle rect in rects)
{
if (rect != exclude)
{
if (rect.Touch(edgeToCheck))
{
hittingRects.Add(rect);
}
}
}
return hittingRects;
}
I can write very basic Linq queries, but I have no idea on this one. I am mainly confused in how to check the exclusion check and how to perform the hit test.
Any help will be appreciated.