How can I reset the contents of my array?

  • Thread starter Thread starter trint
  • Start date Start date
T

trint

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
 
Array.Clear(...)

public static void Clear (
Array array,
int index,
int length
)
 
Array.Clear(...)
public static void Clear (
Array array,
int index,
int length
)
trint said:
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.Length);
 
Aneesh said:
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.Length);

That was what was also in the top post ...

Arne
 
trint said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top