Hey everyone, I've been wondering about this, but can't find anything about it.
Basically, I've got a class, and a list of that class:
Code:
public class Person
{
public Rectangle boundingBox;
public int health;
}
List<Person> personList = new List<Person>();
And I've got a function that takes a list of rectangles:
Code:
private void CheckBoundingBoxes(List<Rectangle> boundingBoxes)
{
// Do stuff...
}
Now, is it possible that instead of doing this to generate a list of rectangles based on each persons bounding box:
Code:
List<Rectangle> boundingBoxList = new List<Rectangle>(personList.Count);
for (int i = 0; i < personList.Count; ++i)
{
boundingBoxList.Add(personList[i].boundingBox);
}
CheckBoundingBoxes(boundingBoxList);
I can just access the bounding box variable directly, something like:
Code:
CheckBoundingBoxes(new List<Rectangle>( personList { boundingBox } ) );
to do the same thing?
I appreciate any help I get in regards to this