# Mulitdimensional array

#### mapworks

##### New member
I am trying to create a report that will give me the area of multiple polygons on a layer. There will be an unknown number of layers and polygons. I was thinking I could use a multidimensional array with each row holding the layer name and the area of that polygon then loop through and separate the layers and sum the areas. My problem is that in all the reading I’ve done on the subject I’m not sure of how to initialize the array. I know how many polygons there will be, but am unclear on how do I do it, and would that be the most efficient way of going about this problem? Any help would be appreciated.

#### LeonR

##### Well-known member
This is a complete long shot, but could you create a class which would take the values for your polygons, and then use arraylist and add objects to it ? If that makes sense.... I'm sure theres a few ways to do it.. I may of misunderstood your question! (or just be wrong! haha)

#### mapworks

##### New member
Leon, thanks for the reply. The problem is that the polygon's layer name must be associated with its area so I can sum all polygon areas on a specific layer (this is a cad program).

#### jmcilhinney

##### VB.NET Forum Moderator
Staff member
You would have a Layer class and somewhere you would have a collection of Layers. A Layer object would have a Polygons property that is a collection of Polygon objects. You can loop through the Layers and, for each Layer, loop though its Polygons.

#### LeonR

##### Well-known member
That's kind of what I was trying to say, but I wasn't 100% sure it was the best method

#### mapworks

##### New member
thanks

gentlemen, thanks for the help, it worked as you said it would.

#### mapworks

##### New member
Okay, so now I have an array with the layer name and the area, now how would i go about looping through it and if the layer exists then sum the area with the final result being a list of all layers with the sum of all polygons on that layer?

Replies
0
Views
239
Replies
2
Views
685
Replies
5
Views
633
Replies
1
Views
488
Replies
0
Views
590