473,782 Members | 2,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to define array ?

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
2 2780
"Jarod" <Ja***@discussi ons.microsoft.c om> 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
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***@discussi ons.microsoft.c om> wrote in message
news:DA******** *************** ***********@mic rosoft.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
29279
by: Roman Mashak | last post by:
Hello, All! I wonder is it possible to define an array containing strings, not single characters? What I want is array 'table' that will have N elements, and every element is a strings tailoring with '\0', like that: table = "string0\0" table = "string1\0" ...
5
11440
by: Stuart Norris | last post by:
Dear Readers, I am attempting to define an array of IPAddress-es in C#. I wish to have a array of address so I can try in order to connect to them in a loop to handle unavailable hosts. Todate since I do not know how to define an array of IPAddress-es. I have been defining variable like:
29
2333
by: Ancient_Hacker | last post by:
It sure would be nice if I could have a macro that add a level of indirection to its argument. So if I write: AddIndirection( X ) The macro AddIndirection will do: #define X (*X) so after that point whenever you use X it gets replaced by (*X)
2
11360
by: marceliogp | last post by:
I have a file.h that have all my definitions and I need to define a array to use in my software, but I don´t know how can I do it. My define´s that cause error: .... #define ERROR_SAMPLE1 123 #define ERROR_SAMPLE2 124 .... #define FUNCTIONS_EMP { 20, 15, 22, 53, 34)
10
5469
by: Zhou Yan | last post by:
I want to define a pointer to a multiple-subscripted array. For instance, I have an array defined as below( I have reduced the size of the array as well as the dimension, but I think it OK to ask this simple case.) /---- int array = { 1, 2, 3, 4 } \-----
23
3922
by: anon.asdf | last post by:
Hello! In the following code-snippet, is it possible to initialize each element of arr, with STRUCT_INIT? struct mystruct { int a; char b; };
5
1857
by: suresh | last post by:
Hi, How to define a two dimensional array where each row is of type vector<map<string,int>>? My idea is, if "x" is such a variable, x is a vector where each cell of the vector is a map<string,int>. Similarly x is a vector where each cell of it is a map<string,int>.
8
7472
by: Susan Bricker | last post by:
Hi. I would like to create an array and use the data to populate some new records when the user clicks on a button (that's the short description). If I were to code the array in C (I know ... not this forum, but it's what I know) I would do it like this ... /* Declare the structure template */ struct recdata { long classID;
5
3472
by: maker.rain1 | last post by:
Hello All, I have come across a problem as explained below in a sample. Please help me if anyone has any ideas to solve this. I have a #define as defined below. #define MAX 200 int _tmain(int argc, _TCHAR* argv)
1
6284
by: lumumba401 | last post by:
Hello everybody, i am asking about how to define a bidimensional dynamic array as a global variable to use as incoming variable in a function Let us see , for example in a part of a programm my problem: #include<iostream> ... using namespace std;
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.