Deleting from an Array

Jay1b

Contributor
Joined
Aug 3, 2003
Messages
640
Location
Kent, Uk.
I am using the following code to store an array in.

Public Structure StructField
Public FieldName As String
Public FieldStartPos As Integer
Public FieldLength As Integer
End Structure

Public Fields(1) As StructField

I would like to delete a particular row in the array where the FieldName = Pants.

Is it possible to delete a row out of an array? If so how?

Thanks.
 
If you use an array list then you can simply use the Remove or RemoveAt method of it. A normal array doesnt have a method like that.
 
Could i combine the two in any way? To assign 'Fields' as a ArrayList to store the struct field in it?

Personally i would much prefer to use a standard array system, but i have been told it must use the structure in there.

Public Fields(1) As StructField
 
To insert things to an array list you can use Insert or InsertRange which can accept an array. Then to move it back to an array you use ToArray method of the ArrayList.
 
So are you saying that i create the array as i am now, then copy the array to an arraylist, delete the record from the arraylist and then copy the arraylist back to the standard array?
 
Back
Top