-
Book Overview & Buying
-
Table Of Contents
.NET 4.0 Generics Beginner's Guide
By :
The following are the best practices to be followed while using Generics:
1. Don't use Generics when you know the situation won't always be generic.
2. Use Stack<T> for a Last In First Out (LIFO) list implementation.
3. Use Queue<T> for a First In First Out (FIFO) implementation.
4. Use List<T> for random access lists with zero-based indexing.
5. Use LinkedList<T> to implement a deque because it offers faster insertion and deletion at both ends as opposed to other collections.
6. If you have to frequently insert random locations in the list, prefer LinkedList<T> over List<T> because LinkedList<T> is a constant time operation to insert one item in between two elements in a linked list.
7. If the random list does not have a duplicate, use HashSet<T> instead. It is the fastest. Check out the performance analysis in Appendix A, Performance Cheat Sheet.
8. Don't use a for loop over a IDictionary<TKey,TValue> implementation...
Change the font size
Change margin width
Change background colour