Steve Tsiki

Steve Tsiki

  • NA
  • 42
  • 0

Use value from one list to another list

Mar 29 2011 6:35 AM
Greetings guys.

I would like to create 2 lists, in which the first one should contain rectangles and the other some kind of objects.

For example:

List<Rectangles> recs = new List<Rectangle>();
List<Object> objs = new List<Object>(); // Object is an example of a class that I have created and named Object
Rectangle rec;
Object obj;

if (something)
{
        rec = new Rectangle(x,y,width,height);
        recs.Add(rec);
        obj = new Object(/* I want this field to be the value of the rectangle previously crearted*/,                 Content.Load<Texture2D>("myImage.jpeg"));
        objs.Add(obj);
}

Any suggestions? Thanks in advance.

Answers (4)