0
What is difference between ArrayList and List ?? Can you explain with example??
2 Respostas
+ 3
ArrayList is a deprecated version of List. With ArrayList it can contain objects of varying type, which is unsafe during iteration and therefore should not be used.
ArrayList Unsafe = new ArrayList();
List<int> Safe = new List<int>();
ArrayList.Add(666);
ArrayList.Add("beast"); // compiler WON'T complain
List.Add(666);
List.Add("beast"); // compiler error
foreach(int Value in Unsafe)... // runtime failure on "beast"
foreach(int Value in Safe)... // all good
0
Did this answer your question? If so would you be so kind as to mark my response as the answer? This is done with the check mark next to my response. Thank you.