Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you clear/erase the data from the string[] array?? 1

Status
Not open for further replies.

fletchsod

Programmer
Dec 16, 2002
181
I don't remember how to clear this string array.

Code:
string[] sDataOneVinArrayStack;

//blah blah... (when array is filled with data)...

sDataOneVinArrayStack.Clear();


The Clear() object does not exist, so what is your normal way of doing this to empty the array stack and start as new all over again.

Thanks...
 
arrays are read-only, so you can't modify them like to can a collection<> or list<>. if you want to clear it you need to replace it.
Code:
string[] strings = new string[] {"a","b","c"};
//reset to empty array
strings = new string[0];
//reset to empty array of the same length;
strings = new string[strings.Length];

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Gotcha! Thanks... I'm used to C and C++ so C# is a little different which I'm trying to get used to. Thanks...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top