New article: Automatic Web Browser|
Old article: 6 common collection classes of C #
Stringcollection, array, arraylist, ilist, item, queue, stack, hashtable,Sortedlist
The arraylist.
Use stack when you need a set that can implement the following.
When you need a set of first-in-first-out, use queue.
If you need an array that can be queried by key value, use hashtable.
Sortedlist.
Csdn help:
Be careful when selecting Class. The incorrect type may restrict your use of the set.
Consider the following:
Do you need a sequence list where elements are generally discarded after retrieving their values?
If necessary, consider using Class or Generic class. Use Class or Generic class.
If not, consider using other collections.
Do I need to access elements in some order, such as FIFO, lifo, or random access?
QueueClass andQueueGeneric classes provide FIFO access.
StackClass andStackGeneric classes provide LIFO access.
Generic classes allow sequential access from the beginning to the end or from the end to the beginning.
Other sets provide random access.
Do I need to access each element through indexes?
And Class and Generic classes provide access to elements through the element index starting from scratch.
, , And Class and And Generic classes provide access to elements through element keys.
And Class and And A generic class provides access to an element through its element index starting from scratch or through its element key.
Will each element contain a combination of values, keys, and values, or a combination of keys and values?
One Value: Use any Interface or A set of generic interfaces.
One key and one value: Use any Interface or A set of generic interfaces.
A value with an embedded key: Use Generic class.
One key and multiple values: UseNamevaluecollectionClass.
Do I need to sort elements in a different way than the input element method?
HashtableClasses are sorted by the hash code of their elements.
SortedlistClass andSorteddictionaryAndSortedlistGeneric classes Interfaces and The implementation of generic interfaces sorts elements by buttons.
ArraylistProvide Method, which acceptsIcomparerImplementation as a parameter. Its corresponding generic class (ListGeneric class) provides Method, which acceptsIcomparerThe implementation of generic interfaces is used as parameters.
Do you need quick search and retrieval of information?
Do I need to accept only the string set?
Stringcollection(Based onIlist) AndStringdictionary(Based onIdictionary) Are located in Namespace.
In addition, you can specify Class, you can use Any generic collection class in the namespace serves as a set of Strong string types.