views:

58

answers:

1

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 property =1

+3  A: 

Simply:

var query = listLines.Where(l => ((Point) l.Tag).X == 1);

If that's not what you're after, please clarify.

Jon Skeet
How to cast l.Tag to Point in this very same line :-)
Tintu Mon
@Tintu: Edited. It's just a cast as if it occurred anywhere else.
Jon Skeet
Thanks Skeet.Guess that will solve my issue.
Tintu Mon