473,397 Members | 1,950 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,397 software developers and data experts.

How can I reset the contents of my array?

Hi,
I have several arrays that look like this:

string[] productsString0 = new string[1000];

After they are no longer needed, How can I reset them as though the
program were just started?
Thanks,
Trint

Jun 4 '07 #1
5 16670
Array.Clear(...)

public static void Clear (
Array array,
int index,
int length
)

trint wrote:
Hi,
I have several arrays that look like this:

string[] productsString0 = new string[1000];

After they are no longer needed, How can I reset them as though the
program were just started?
Thanks,
Trint
Jun 4 '07 #2
On Jun 4, 11:02 am, Daniel Cigic <daniel.ci...@googlemail.comwrote:
Array.Clear(...)

public static void Clear (
Array array,
int index,
int length
)

trint wrote:
Hi,
I have several arrays that look like this:
string[] productsString0 = new string[1000];
After they are no longer needed, How can I reset them as though the
program were just started?
Thanks,
Trint- Hide quoted text -

- Show quoted text -
Thanks!

Jun 4 '07 #3
On Jun 4, 8:27 pm, trint <trinity.sm...@gmail.comwrote:
On Jun 4, 11:02 am, Daniel Cigic <daniel.ci...@googlemail.comwrote:


Array.Clear(...)
public static void Clear (
Array array,
int index,
int length
)
trint wrote:
Hi,
I have several arrays that look like this:
string[] productsString0 = new string[1000];
After they are no longer needed, How can I reset them as though the
program were just started?
Thanks,
Trint- Hide quoted text -
- Show quoted text -

Thanks!- Hide quoted text -

- Show quoted text -
Use clear method from Array class -
Array.Clear(productsString0,0,productsString0.Leng th);

Jun 4 '07 #4
Aneesh P wrote:
On Jun 4, 8:27 pm, trint <trinity.sm...@gmail.comwrote:
>On Jun 4, 11:02 am, Daniel Cigic <daniel.ci...@googlemail.comwrote:
>>Array.Clear(...)
public static void Clear (
Array array,
int index,
int length
)
trint wrote:
I have several arrays that look like this:
string[] productsString0 = new string[1000];
After they are no longer needed, How can I reset them as though the
program were just started?
Trint- Hide quoted text -
- Show quoted text -
Thanks!- Hide quoted text -

- Show quoted text -

Use clear method from Array class -
Array.Clear(productsString0,0,productsString0.Leng th);
That was what was also in the top post ...

Arne
Jun 9 '07 #5
trint wrote:
I have several arrays that look like this:

string[] productsString0 = new string[1000];

After they are no longer needed, How can I reset them as though the
program were just started?
Other has suggested Array.Clear, but in many circumstance you
would just let it go out of scope and have the garbage collector
take care of everything.

Arne
Jun 9 '07 #6

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

Similar topics

18
by: pauld | last post by:
Ive tried almost every combination of while,foreach, key, value , array,0 I can some up with Ive got an associative array that Ive been using as a counter eg if (blah blah blah ) {$array++}...
28
by: Terry Andersen | last post by:
I have an array that I initialize to zero, like: Buffer = {0x00}; How do I in my code reset this array to all zeros ones more? Without running a whole for loop? Best Regards Terry
14
by: Rick | last post by:
Hi, This is probably piece of cake for you C gurus but it is giving me a headache. I'm still not really used with pointers and chars so many things are going wrong. Practicing makes wonders but...
5
by: ritchie | last post by:
Hi, I am writing to ask if anyone can see why my array is not being sorted correctly? It's an array of 4 elements(ints 1,2,3,4) but after calling the selection sort it comes back sorted as...
3
by: 0to60 | last post by:
I can declare and initialize a managed array of managed types like this: System::Object* array __gc = {...} Now, what do I do if I wanna reset that array to something else without...
3
by: Crirus | last post by:
I have a big array 512*512 elements Wich is the best way to reset the array to 0 on each element? Redim without preserve, I have for loop and clear shared function Wich one is best optimised for...
6
by: Skeleton Man | last post by:
Hi all, I'm after the PHP equivlent to this Perl construct: print @{}; In the above example someFunctionCall() would return an array, and we're printing the first item from the returned...
5
by: bdbeames | last post by:
I have and array that I fill with elements in a function. I call it later and want to reset it so that it is empty so I can fill it with different elements and a different number of elements. How...
1
by: BiraRai | last post by:
is it possible to add new variable to a array object at run time? the following code does not work. $iterator->current()-> = 1234; how can this be done? function...
8
by: SM | last post by:
Hello, I've done some research on how to grab the first key of a multidimensional array. I've came up with a couple of solutions. Wich is the best?. If possible, can it be done in just one line of...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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.