473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Reusing string arrays

I need to store a set of strings (filenames and paths in fact) in a
dynamic string array as in:

MyArray = Directory.Getfiles (etc)

This array needs module scope but is populated as above in a procedure
that will be called frequently to look at a changing folder contents.

The question is whether I need to (or it's good practice to) clear the
array each time before it's populated, ie presumably by:

Erase MyArray
MyArray = Directory.Getfiles (etc)

and since first time through the array will have been declared but not
populated, possibly what I should have is:

If Not MyArray is Nothing Then Erase MyArray
MyArray = Directory.Getfiles (etc)

Or is this a detail issue of no real consequence?

TIA
JGD
Nov 21 '05 #1
2 1141
"John Dann" <ne**@prodata.co.uk> schrieb:
I need to store a set of strings (filenames and paths in fact) in a
dynamic string array as in:

MyArray = Directory.Getfiles (etc)

This array needs module scope but is populated as above in a procedure
that will be called frequently to look at a changing folder contents.

The question is whether I need to (or it's good practice to) clear the
array each time before it's populated, ie presumably by:

Erase MyArray
MyArray = Directory.Getfiles (etc)

and since first time through the array will have been declared but not
populated, possibly what I should have is:

If Not MyArray is Nothing Then Erase MyArray
MyArray = Directory.Getfiles (etc)

Or is this a detail issue of no real consequence?


You don't need to clear the array. Just type 'MyArray =
Directory.GetFiles(...)'.

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

Nov 21 '05 #2
John,
MyArray = Directory.Getfiles (etc)


What you are doing with this is setting the reference from MyArray to the
reference from the Array you have created in Directory.Getfiles(ect).

It is not a copy of an array or something.

I hope this gives the idea?

Cor
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Java script Dude | last post by:
Some programmers prefer to stay with native level data structures such as string arrays instead of using Object based data structures such as ArrayList. From and efficiency point of view. Are...
9
by: Alan | last post by:
Using VC++ (1998) compiler with PFE32 editor in Win2K Pro SP4. (DigitalMars CD on order. ) The program (below) instantiates a class and then deletes it. I would have thought that reusing the...
16
by: Don Starr | last post by:
When applied to a string literal, is the sizeof operator supposed to return the size of the string (including nul), or the size of a pointer? For example, assuming a char is 1 byte and a char *...
4
by: Old Wolf | last post by:
#include <stdio.h> #include <stdarg.h> Is this safe: void foo(const char *fmt, ...) { va_list ap; va_start(ap,fmt);
4
by: Simon Schaap | last post by:
Hello, I have encountered a strange problem and I hope you can help me to understand it. What I want to do is to pass an array of chars to a function that will split it up (on every location where...
17
by: Chad Myers | last post by:
I've been perf testing an application of mine and I've noticed that there are a lot (and I mean A LOT -- megabytes and megabytes of 'em) System.String instances being created. I've done some...
4
by: Tedb | last post by:
Is there any reason why you can't reuse a delegate object instance versus creating a new one each time? For example in the following scenario I have a DataPoints object with an array of DataPoint...
2
by: tshad | last post by:
I have some code that is exactly the same except for 1 name. In the "for loops" below the 2nd parameters change as they are pointing to separate string arrays in the structure: ...
18
by: greenflame | last post by:
I want to make a function that does the following. I will call it thefunc for short. '||Char>>' I tried the following def thefunc(s): s = "||" + s + ">>"
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.