LinQ to collection a basic question
This may be too simple.Please help.
List<Line> listLines = new List<Line>();
foreach (Point p in currentPointsLines)
{
Line l = new Line();
l.Tag = p;
l.X1 = AnotherList[(int)p.X].CenterX; //AnotherList is of type Rectangle
l.Y1 = AnotherList[(int)p.X].CenterY;
l.X2 = AnotherList[(int)p.Y].CenterX;
l.Y2 = AnotherList[(int)p.Y].CenterY;
listLines.Add(l);
}
Now I would like to query this listLines collection to get another collection of lines having x co-ordinate of Tag prope开发者_开发问答rty =1
Simply:
var query = listLines.Where(l => ((Point) l.Tag).X == 1);
If that's not what you're after, please clarify.
精彩评论