1

I've been searching for an example for array of arrays but I couldn't find any. Any link or explanation will be great.

What I'm really trying to do: I have angles and edges of polygons and I want to insert those informations inside array, It looks like this at the time:

Dim edges() as integer
Dİm angles() as integer
??Dim ArrayOfArray as integer??

Private sub AddPolygonToArray
for i = 0 to x
edges(i) = edge
angles(i) = angle
next
??ArrayOfArray(index) = new Array(edges,angles,NameOfPolygon,QuantityOfPolygon)??
End Sub
  • Index,nameofpolygon and quantityofpolygon are not necessary, but they're integers if you need to know. If anything is incomprhensible, don't be afraid to ask. Thanks in advance
7
  • 2
    Resizing arrays is a Very Bad Idea. Use a List(Of Polygon) instead. Commented Jul 10, 2014 at 19:06
  • Thanks for your answer but where will I keep Informations to draw the polygon, it'll be better if there's only one array instead of 4. Can you please explain what do you mean when saying list of polygon? Commented Jul 10, 2014 at 19:09
  • 1
    There's only one list. Your Polygon class should have an Edge and Angle property. This is covered well in any introductory book for VB.NET, pay a visit to your local library. Commented Jul 10, 2014 at 19:12
  • 1
    You are better off putting the information inside a class or a structure instead of having a multidimentional array. Commented Jul 10, 2014 at 19:24
  • 2
    I agree with Hans: this should be handled in a more object oriented way, since we have the tools available. I believe what you are asking for is a multidimensional array, which is unnecessary in this day in age. There are rare cases when it can be a good idea for raw performance (i.e. cryptography algorithms), but this doesn't appear to be one of those cases. Commented Jul 10, 2014 at 19:26

2 Answers 2

2

There are two types of multidimensional Arrays

Regular multidimensional array

Dim mdArray(5, 5, 5) as integer

And Jugged Array (Array of Arrays)

Dim jugged()() as integer

Since geometry is all about 3 dimensions, I believe, you can describe any shape using 3-dimentional array such as mdArray(5, 5, 5)

Sign up to request clarification or add additional context in comments.

Comments

1

You should do a List(Of Polygon).

But if you can't, you can always do a Multidimensional Array

This means that you can do

Dim MultiArray(X,Y,Z,W)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.