0

What is difference between ArrayList and List ?? Can you explain with example??

25th Apr 2017, 3:54 PM
khemraj katkar
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
25th Apr 2017, 5:48 PM
Mason Krei
Mason Krei - avatar
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.
28th Apr 2017, 6:09 PM
Mason Krei
Mason Krei - avatar