Cybertof,
Here are the differences:
MyArrayList2 = MyArrayList;
This will just copy the reference to MyArrayList into MyArrayList2. If
you add an element to MyArrayList2, then you will see that in MyArrayList,
because they both point to the same thing.
MyArrayList2 = MyArrayList.Clone();
This will create a shallow copy of the ArrayList. If the elements are a
reference, then those references are copied. If they are value types, then
that is copied to the new array list. Now, if they are all reference types,
then the two array lists are pointing to the same objects. However, if you
add a new item to MyArrayList2, then it will not be shown in MyArrayList,
because MyArrayList2 is a new object, not a reference to the same
MyArrayList.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Cybertof" <cy****************@gmx.net> wrote in message
news:MP************************@msnews.microsoft.c om...
Hello,
Can someone explain me what is the differences between these 2 lines of
code :
MyArrayList2 = MyArrayList;
MyArrayList2 = MyArrayList.Clone();
MyArrayList/MyArrayList2 are aray lists of class objects implementing
the CompareTo() method, so the list is sortable.
What happens if i make this call : MyArrayList2.Sort() ?
Will MyArrayList be sorted too ?
Regards,
Cybertof.