The difference between ArrayList and List in the c#
When discussing the data structure in C#, understanding the difference between ArrayList and List is very important. Both categories have played a key role in the collection of management objects, but they have different operation methods.
Question: What is the difference between ArrayList and List in C#?
Answer: The main difference is the existence of type constraints. List is a generic class that allows it to force the type to be safe and store the value of specific types. This eliminates the need for mandatory conversion and ensures data integrity.
On the other hand, the ArrayList storage object quotes and lacks type specificity. This method causes performance loss when treating the value type because the overhead related to the box and the box dismantling.Other considerations:
List supports generics Ienumeraable
interface, making it very suitable for use with Languch Integration Query (Linq) operation. This provides a more concise and efficient code than using ArrayList. ArrayList needs to be explicitly converted or Office calls. ArrayList is considered a retention class that introduced before the generic is added to C#. It has now been abandoned, and it is recommended to use it only when interacting with the left still relying on it.
The above is the detailed content of What's the Difference Between `ArrayList` and `List` in C#?. For more information, please follow other related articles on the PHP Chinese website!