Hello,
I want to enter 4 names in an array and then I want to clear it completely so that I can enter 4 new names. I have tried the Array.Clear(names) thing, but it is not working. Is that the right way to do it?
Thanks!
Printable View
Hello,
I want to enter 4 names in an array and then I want to clear it completely so that I can enter 4 new names. I have tried the Array.Clear(names) thing, but it is not working. Is that the right way to do it?
Thanks!
Quoted from http://www.c-sharpcorner.com/Code/20...WithArrays.asp
Hope this helps. I tested it and it worked for me. :)
"The Clear static method of the Array class removes all items of an array and sets its length to zero. This method takes three parameters – first an array object, second starting index of the array and third is number of elements. The following code removes two elements from the array starting at index 1 (means second element of the array). "
Array.Clear(names, 1, 2);
James
Hmmm....I have tried that and it is not working. I will have to take another look. Thanks