While I certainly recommend that you switch from non-generic to generic collections for a variety of good reasons, I honestly doubt that these collections can cause your performance problems. Boxing, as a rule, is only a problem when you get to the microscopic level, demanding to squeeze out tiny benefits in high-performance situations. It is also useful to avoid general GC considerations, but this is usually negligible in this arena.
In other words: it is very doubtful that boxing will cause a performance problem that your users would notice.
Obviously, I am talking in generalizations. Without knowing your specific scenario, I cannot say so with certainty.
Change Please note that although I am skeptical about your problem, you can use non-general collections, I will indicate that this It is very important what type you use to solve this problem, especially when the amount of data in the collection is large. Here are just a few examples:
- If you perform a key-based search, a hash table such as
Dictionary<TKey, TValue> is significantly superior, for example, to List<T> . - If you check for duplicates,
HashSet<T> will have excellent performance. - If you are looking for FIFO (queuing behavior),
Queue<T> will have excellent performance. - If you do insert / delete at random positions in a collection,
LinkedList<T> will have excellent performance.
These collections should be part of any .NET developer toolkit (indeed, any developer). If you use a List<T> (or ArrayList ) or similar data structure wherever you use item collections, this can very well lead to performance problems in the future - again, especially when your collections are large. I'm not talking about trivial performance indicators. Therefore, be careful to make the smart choice for your types of collections.
But I would recommend a performance profiler in general, such as ANTS (good, but not free) or EQATEC (also good and free). Just run the application as part of a program, such as one of them, and see where your bottlenecks are. I assume that you will find that these are not your non-general collections; but naturally, I could be wrong.
source share