PC Review


Reply
Thread Tools Rate Thread

How to define array ?

 
 
=?Utf-8?B?SmFyb2Q=?=
Guest
Posts: n/a
 
      23rd Oct 2004
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
 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      23rd Oct 2004
"Jarod" <(E-Mail Removed)> 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/>


 
Reply With Quote
 
chanmmn
Guest
Posts: n/a
 
      23rd Oct 2004
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" <(E-Mail Removed)> wrote in message
newsA436C27-86AB-45B6-9C31-(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to define struct with array in C#? Polaris Microsoft C# .NET 2 13th Mar 2008 12:22 PM
How to Define and Use a Dynamic Array Chaplain Doug Microsoft Excel Programming 5 4th Dec 2007 09:19 PM
Define a table as an array =?Utf-8?B?QWxleA==?= Microsoft Access VBA Modules 1 11th Jan 2005 05:15 AM
Define an array Charles Microsoft Excel Worksheet Functions 17 8th Oct 2004 03:10 AM
Define datacolumn array Bucket Microsoft VC .NET 0 9th Jul 2003 04:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:57 PM.