Is it possible to create many arrays using a for loop?

3 views
Skip to first unread message

Gene

unread,
Jan 1, 2004, 2:58:34 AM1/1/04
to
I want to create a certain number of arrays on the same time to use,
is it possible to do that?


Cor

unread,
Jan 1, 2004, 4:05:34 AM1/1/04
to
> I want to create a certain number of arrays on the same time to use,
> is it possible to do that?

Why should it not be possible?

Cor


Gene

unread,
Jan 1, 2004, 6:12:16 AM1/1/04
to
Could you teach me how to do it???
THX!

"Cor" <n...@non.com> 撰寫於郵件新聞:u5JfjaE...@tk2msftngp13.phx.gbl...

Gene

unread,
Jan 1, 2004, 6:14:14 AM1/1/04
to
p.s.
I mean using a for loop and controlling how many arrays to create

"Gene" <euge...@hotmail.com> 撰寫於郵件新聞
:O4xyZgF0...@TK2MSFTNGP10.phx.gbl...

Herfried K. Wagner [MVP]

unread,
Jan 1, 2004, 7:00:10 AM1/1/04
to
* "Gene" <euge...@hotmail.com> scripsit:

> I want to create a certain number of arrays on the same time to use,
> is it possible to do that?

Where do you want to store the arrays? In an other array? In an
arraylist?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Cor

unread,
Jan 1, 2004, 7:16:06 AM1/1/04
to
Hi Gene,

I made an example here

I hope this makes it more clear and if not feel free to ask?

Cor
\\\
Option Strict On
Public Module Main
' Sample of an arraylist that itself contains 10 classic arrays.
Public Sub Main()
Dim a As New ArrayList
Dim B() As Integer = {1, 2, 3, 4}
For i As Integer = 0 To 9
a.Add(B)
Next
MessageBox.Show(DirectCast(a(9), IList)(2).ToString)
'With option strict off you do not
'have to use the directcast but and than it is
'MessageBox.Show(a(2)(2).ToString) 'but I would not do that
'I show this to make it more classic looking for you.
End Sub
End Module
///

"Gene" <euge...@hotmail.com> schreef in bericht
news:u9dDghF0...@TK2MSFTNGP10.phx.gbl...

Gene

unread,
Jan 1, 2004, 7:59:33 AM1/1/04
to
it's quite clear, THX!!!

"Cor" <n...@non.com> 撰寫於郵件新聞:uedRBFG0...@TK2MSFTNGP11.phx.gbl...

Gene

unread,
Jan 1, 2004, 8:01:56 AM1/1/04
to
At first, I simply think of store the arrays in an other array,
but in Cor's example, I see it can store in an arraylist.
I think i will do that.
Do you have any other suggestions???

"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at>
???????:#nKvt9F0...@TK2MSFTNGP11.phx.gbl...

Pepi Tonas

unread,
Jan 1, 2004, 9:27:11 AM1/1/04
to
On 01 Jan 2004 13:00:10 +0100, hirf-spa...@gmx.at (Herfried K.
Wagner [MVP]) wrote:

>* "Gene" <euge...@hotmail.com> scripsit:
>> I want to create a certain number of arrays on the same time to use,
>> is it possible to do that?
>
>Where do you want to store the arrays? In an other array? In an
>arraylist?

What would be the difference between storing arrays in arraylists and
in another array?

Thanks...

Herfried K. Wagner [MVP]

unread,
Jan 1, 2004, 12:35:08 PM1/1/04
to
* Pepi Tonas <Pepi...@hotmail.com> scripsit:

>>> I want to create a certain number of arrays on the same time to use,
>>> is it possible to do that?
>>
>> Where do you want to store the arrays? In an other array? In an
>> arraylist?
>
> What would be the difference between storing arrays in arraylists and
> in another array?

An arraylist is a highly dynamic datastructure, you can easily add
elements. When adding an element to an array ('ReDim Preserve'), the
whole array will be recreated which may cause a performance "breakdown".

Herfried K. Wagner [MVP]

unread,
Jan 1, 2004, 12:35:49 PM1/1/04
to
* "Gene" <euge...@hotmail.com> scripsit:

> At first, I simply think of store the arrays in an other array,
> but in Cor's example, I see it can store in an arraylist.
> I think i will do that.
> Do you have any other suggestions???

I had a look at Cor's code and I think it solves the problem in a clean
way. I would use an 'ArrayList' too.

Pepi Tonas

unread,
Jan 1, 2004, 6:52:12 PM1/1/04
to
Thanks...

On 01 Jan 2004 18:35:08 +0100, hirf-spa...@gmx.at (Herfried K.

Reply all
Reply to author
Forward
0 new messages