Archive for October, 2007

.NET 2.0 Generic Collections to 1.0 and 1.1 Collections

22 October 2007

I am always looking around for the Generic equivalents for the non-generic collections. Especially when converting 1.1 code over to 2.0

.comptable td
{
border-bottom: 1px solid #008000;
background-color: #ebf7ff;
}
.comptable .name
{
background-color: #a8cece;
}

Table of Generic Collections to Non-Generic Collections

Non-Generic (1.x)
Generic Replacements (2.0+)

ArrayList
List<T>

CollectionBase
Collection<T>

Comparer
Comparer<T>

CompatibleComparer
Comparer<T>

DictionaryBase
KeyedCollection<TKey,TItem>

Hashtable
Dictionary<TKey,TValue>

ICollection
ICollection<T>

IDictionary
IDictionary<TKey,TValue>

IList
IList<T>

Queue
Queue<T>

ReadOnlyCollectionBase
ReadOnlyCollection<T>

SortedList
SortedList<TKey, TValue>

Stack
Stack<T>

 
 

 
Performance
List<T> : a List<T> uses an underlying array that maintains order, thus inserting and removing from this object [...]