By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,916 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,916 IT Pros & Developers. It's quick & easy.

How to define array ?

P: n/a
Hello
I am curious how should I use the array of doubles. The problem is I don't
know in advance how much elements would it have, but I can be sure it will be
less then let's say 150 or 500. So should I define the largest one or use an
arraylist ? I don't resize it, because after a few calculation the
application will be closed. It works like that : read the file, make
calculations, save the file , close. I could count the rows in a file and
then define an array but isn't it waste of time ?
Jarod
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Jarod" <Ja***@discussions.microsoft.com> schrieb:
I am curious how should I use the array of doubles. The problem is I don't
know in advance how much elements would it have, but I can be sure it will be less then let's say 150 or 500. So should I define the largest one or use an arraylist ? I don't resize it, because after a few calculation the
application will be closed. It works like that : read the file, make
calculations, save the file , close. I could count the rows in a file and
then define an array but isn't it waste of time ?


If you know the maximum number of items and it's not too high, use an array.

If you know the avg. line length, divide the length of the file by the avg.
line length and use this number + n as size for your array.

If you don't know anything about the data, an arraylist might be the better
choice.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2

P: n/a
Don't use array and try to use collection instead. We are talking about
VB.NET and not C language. In C you need a hard pointer for dynamic memory
but in today VB.NET you can use collection.

http://msdn.microsoft.com/library/de...Collection.asp

good luck.
chanmm

"Jarod" <Ja***@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.com...
Hello
I am curious how should I use the array of doubles. The problem is I don't
know in advance how much elements would it have, but I can be sure it will
be
less then let's say 150 or 500. So should I define the largest one or use
an
arraylist ? I don't resize it, because after a few calculation the
application will be closed. It works like that : read the file, make
calculations, save the file , close. I could count the rows in a file and
then define an array but isn't it waste of time ?
Jarod

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.