Re: arraylist copy



Try the .Clone() method of the ArrayList.

Marcie

On 8 Apr 2005 09:24:51 -0700, "Sam" <samuel.berthelot@xxxxxxxx> wrote:

>Hi,
>
>I have the following code :
>
>Dim rNodeList As New ArrayList
>Dim rNodeListNew As New ArrayList
>
>For iCntr As Integer = 0 To tvRelations.Nodes.Count - 1
> rNodeList.Add(tvRelations.Nodes(iCntr).Text)
>Next
>
>rNodeListNew = rNodeList
>rNodeList.RemoveAt(2)
>
>after I've filled rNodeList, it contains 8 elements.
>So does rNodeListNew
>
>But when I remove the element 2 of rNodeList, it is also removed in
>rNodeListNew. Why ? Do they both point to the same memory location ?
>How can I prevent that in vb ?
>
>Thx

.



Relevant Pages

  • Re: arraylist copy
    ... Do I have the functions of the Clone and CopyTo ... >>Dim rNodeListNew As New ArrayList ...
    (microsoft.public.dotnet.languages.vb)
  • Re: arraylist copy
    ... TIA, ... John ... >> Dim rNodeListNew As New ArrayList ...
    (microsoft.public.dotnet.languages.vb)
  • Re: arraylist copy
    ... Switch the line rNodeListNew = rNodeList to: ... then both arraylists will still point to the same objects. ... > Dim rNodeListNew As New ArrayList ...
    (microsoft.public.dotnet.languages.vb)
  • arraylist copy
    ... Dim rNodeListNew As New ArrayList ... Thx ... Prev by Date: ...
    (microsoft.public.dotnet.languages.vb)