In programming, container objects are inevitably used to accommodate a certain number of objects. Microsoft's. NET programming platform is really convenient. It provides an arraylist object to meet most of the container object requirements during programming. But is that true?
Arraylist mainly provides an index-based container, but it also provides the contains function, so that you can write the function by content, but this is not necessarily efficient. In fact, in many cases, it is easier to use a key-based container to reduce traversal, and the function efficiency will obviously increase a lot.
The following are some experiences:
- Arraylist meets most requirements;
- The queue or stack is used only when it needs to be deleted after reading;
- If you need access based on keys rather than indexes, You need to select hashtable-multiple elements or listdictionary-a small number of elements;
- Do not use collection classes with redundant features;
Modify according to the four principlesCodeThe memory required for code running is significantly reduced, especially the memory peak, which is greatly reduced.