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:
public class Person
{
public Rectangle boundingBox;
public int health;
}
List personList = new List();
|
And I've got a function that takes a list of rectangles:
private void CheckBoundingBoxes(List boundingBoxes)
{
// Do stuff...
}
|
Now, is it possible that instead of doing this to generate a list of rectangles based on each persons bounding box:
List boundingBoxList = new List(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:
CheckBoundingBoxes(new List( personList { boundingBox } ) );
|
to do the same thing?
I appreciate any help I get in regards to this :)
naura paxPosted Jul 8, 2009, 2:27 AM
I don't think you can do that. You can create a list of a type.Person.rectangleBox is a datamember not a type, nor you can pass values to create a list (at least not with new keyword).
But maybe I'm wrong..