.NET Collection Overview

.NET collection overview image

IEnumerator – A Forward Const Iterator
IEnumerator defines an enumerator, which is an analogy of forward const iterator. "Forward" means enumerator can move in only one direction - forward. "Const" means that it cannot change the underlying collection. Current property is read-only.

IEnumerator Interface
// Summary:
// Supports a simple iteration over a nongeneric collection.
public interface IEnumerator
{
// Summary:
// Gets the current element in the collection.
//
// Returns:
// The current element in the collection.
object Current { get; }
// Summary:
// Advances the enumerator to the next element of the collection.
//
// Returns:
// true if the enumerator was successfully advanced to the next element; false
// if the enumerator has passed the end of the collection.
//
// Exceptions:
// System.InvalidOperationException:
// The collection was modified after the enumerator was created.
bool MoveNext();
//
// Summary:
// Sets the enumerator to its initial position, which is before the first element
// in the collection.
//
// Exceptions:
// System.InvalidOperationException:
// The collection was modified after the enumerator was created.
void Reset();
}
view raw IEnumerator.cs hosted with ❤ by GitHub
IEnumerator<T> Interface
// Summary:
// Supports a simple iteration over a generic collection.
//
// Type parameters:
// T:
// The type of objects to enumerate.This type parameter is covariant. That is,
// you can use either the type you specified or any type that is more derived.
// For more information about covariance and contravariance, see Covariance
// and Contravariance in Generics.
public interface IEnumerator<out T> : IDisposable, IEnumerator
{
// Summary:
// Gets the element in the collection at the current position of the enumerator.
//
// Returns:
// The element in the collection at the current position of the enumerator.
T Current { get; }
}
view raw IEnumeratorT.cs hosted with ❤ by GitHub

Objects that implement IEnumerator are usually returned from IEnumerable.GetEnumerator(). By convention, new enumerator points to a location "just before" the beginning of the collection. You should call MoveNext() to move the enumerator to the first element of the collection.  MoveNext() will return false if collection is empty.


IEnumerable – An Enumerable Collection with Read-Only Forward-Only Access
IEnumerable is implemented by virtually all .NET collections. It defines a single method - GetEnumerator(). This method returns an enumerator for the collection. Any object that implements IEnumerable can be used with the foreach operator.

IEnumerable Interface
// Summary:
// Exposes the enumerator, which supports a simple iteration over a non-generic
// collection.
public interface IEnumerable
{
// Summary:
// Returns an enumerator that iterates through a collection.
//
// Returns:
// An System.Collections.IEnumerator object that can be used to iterate through
// the collection.
IEnumerator GetEnumerator();
}
view raw IEnumerable.cs hosted with ❤ by GitHub
IEnumerable<T> Interface
// Summary:
// Exposes the enumerator, which supports a simple iteration over a collection
// of a specified type.
//
// Type parameters:
// T:
// The type of objects to enumerate.This type parameter is covariant. That is,
// you can use either the type you specified or any type that is more derived.
// For more information about covariance and contravariance, see Covariance
// and Contravariance in Generics.
public interface IEnumerable<out T> : IEnumerable
{
// Summary:
// Returns an enumerator that iterates through the collection.
//
// Returns:
// A System.Collections.Generic.IEnumerator<T> that can be used to iterate through
// the collection.
IEnumerator<T> GetEnumerator();
}
view raw IEnumerableT.cs hosted with ❤ by GitHub


IQueryable – evaluate queries against a specific data source
IQueryable allows you to define parts of a query against a remote LINQ provider in multiple steps, and with deferred execution.
LINQ queries against IEnumerable<T> produce delegates (methods) which, when invoked, perform the described query. LINQ queries against IQueryable<T> produce expression trees, a data structure which represents the code that produced the query. LINQ providers such as LINQ to SQL interpret these data structures, generating the same query on the target platform (T-SQL in this case).

IQuerable Interface
// Summary:
// Provides functionality to evaluate queries against a specific data source
// wherein the type of the data is not specified.
public interface IQueryable : IEnumerable
{
// Summary:
// Gets the type of the element(s) that are returned when the expression tree
// associated with this instance of System.Linq.IQueryable is executed.
//
// Returns:
// A System.Type that represents the type of the element(s) that are returned
// when the expression tree associated with this object is executed.
Type ElementType { get; }
//
// Summary:
// Gets the expression tree that is associated with the instance of System.Linq.IQueryable.
//
// Returns:
// The System.Linq.Expressions.Expression that is associated with this instance
// of System.Linq.IQueryable.
Expression Expression { get; }
//
// Summary:
// Gets the query provider that is associated with this data source.
//
// Returns:
// The System.Linq.IQueryProvider that is associated with this data source.
IQueryProvider Provider { get; }
}
view raw IQueryable.cs hosted with ❤ by GitHub
IQuerable<T> Interface
// Summary:
// Provides functionality to evaluate queries against a specific data source
// wherein the type of the data is known.
//
// Type parameters:
// T:
// The type of the data in the data source.This type parameter is covariant.
// That is, you can use either the type you specified or any type that is more
// derived. For more information about covariance and contravariance, see Covariance
// and Contravariance in Generics.
public interface IQueryable<out T> : IEnumerable<T>, IQueryable, IEnumerable
{
}
view raw IQueryableT.cs hosted with ❤ by GitHub
IQueryProvider Interface
// Summary:
// Defines methods to create and execute queries that are described by an System.Linq.IQueryable
// object.
public interface IQueryProvider
{
// Summary:
// Constructs an System.Linq.IQueryable object that can evaluate the query represented
// by a specified expression tree.
//
// Parameters:
// expression:
// An expression tree that represents a LINQ query.
//
// Returns:
// An System.Linq.IQueryable that can evaluate the query represented by the
// specified expression tree.
IQueryable CreateQuery(Expression expression);
//
// Summary:
// Constructs an System.Linq.IQueryable<T> object that can evaluate the query
// represented by a specified expression tree.
//
// Parameters:
// expression:
// An expression tree that represents a LINQ query.
//
// Type parameters:
// TElement:
// The type of the elements of the System.Linq.IQueryable<T> that is returned.
//
// Returns:
// An System.Linq.IQueryable<T> that can evaluate the query represented by the
// specified expression tree.
IQueryable<TElement> CreateQuery<TElement>(Expression expression);
//
// Summary:
// Executes the query represented by a specified expression tree.
//
// Parameters:
// expression:
// An expression tree that represents a LINQ query.
//
// Returns:
// The value that results from executing the specified query.
object Execute(Expression expression);
//
// Summary:
// Executes the strongly-typed query represented by a specified expression tree.
//
// Parameters:
// expression:
// An expression tree that represents a LINQ query.
//
// Type parameters:
// TResult:
// The type of the value that results from executing the query.
//
// Returns:
// The value that results from executing the specified query.
TResult Execute<TResult>(Expression expression);
}

IObservable, IObserver 
IObservable defines a provider for push-based notification, IObserver provides a mechanism for receiving push-based notifications. IObserver and IObservable is actually the mathematical dual of IEnumerable and IEnumerator.

IObservable<T> Interface
// Summary:
// Defines a provider for push-based notification.
//
// Type parameters:
// T:
// The object that provides notification information.This type parameter is
// covariant. That is, you can use either the type you specified or any type
// that is more derived. For more information about covariance and contravariance,
// see Covariance and Contravariance in Generics.
public interface IObservable<out T>
{
// Summary:
// Notifies the provider that an observer is to receive notifications.
//
// Parameters:
// observer:
// The object that is to receive notifications.
//
// Returns:
// A reference to an interface that allows observers to stop receiving notifications
// before the provider has finished sending them.
IDisposable Subscribe(IObserver<T> observer);
}
view raw IObservableT.cs hosted with ❤ by GitHub
IObserver<T> Interface
// Summary:
// Provides a mechanism for receiving push-based notifications.
//
// Type parameters:
// T:
// The object that provides notification information.This type parameter is
// contravariant. That is, you can use either the type you specified or any
// type that is less derived. For more information about covariance and contravariance,
// see Covariance and Contravariance in Generics.
public interface IObserver<in T>
{
// Summary:
// Notifies the observer that the provider has finished sending push-based notifications.
void OnCompleted();
//
// Summary:
// Notifies the observer that the provider has experienced an error condition.
//
// Parameters:
// error:
// An object that provides additional information about the error.
void OnError(Exception error);
//
// Summary:
// Provides the observer with new data.
//
// Parameters:
// value:
// The current notification information.
void OnNext(T value);
}
view raw IObserverT.cs hosted with ❤ by GitHub

ICollection – Synchronizable Collection with Count
ICollection defines a collection with Count. It defines IsSynchronized and SyncRoot properties that deal with multi-threaded access to the collection and if collection gets modified by other threads, its enumerators are invalidated and throw InvalidOperationException if used. If IsSynchronized is true, synchronization is built-in into collection operations, and collection can be used safely from multiply threads. If IsSynchronized is false, it means that collection operations are not thread-safe, and user must lock the collection instance, or use some other synchronization mechanism if he wants to work with the collection from several threads. SyncRoot is apparently supposed to return an un-synchronized version of given collection. Note that IEnumerable and IEnumerator and ICollection<T> totally ignore this issue. IReadOnlyCollection represents a strongly-typed, read-only collection of elements.

ICollection Interface
// Summary:
// Defines size, enumerators, and synchronization methods for all nongeneric
// collections.
public interface ICollection : IEnumerable
{
// Summary:
// Gets the number of elements contained in the System.Collections.ICollection.
//
// Returns:
// The number of elements contained in the System.Collections.ICollection.
int Count { get; }
//
// Summary:
// Gets a value indicating whether access to the System.Collections.ICollection
// is synchronized (thread safe).
//
// Returns:
// true if access to the System.Collections.ICollection is synchronized (thread
// safe); otherwise, false.
bool IsSynchronized { get; }
//
// Summary:
// Gets an object that can be used to synchronize access to the System.Collections.ICollection.
//
// Returns:
// An object that can be used to synchronize access to the System.Collections.ICollection.
object SyncRoot { get; }
// Summary:
// Copies the elements of the System.Collections.ICollection to an System.Array,
// starting at a particular System.Array index.
//
// Parameters:
// array:
// The one-dimensional System.Array that is the destination of the elements
// copied from System.Collections.ICollection. The System.Array must have zero-based
// indexing.
//
// index:
// The zero-based index in array at which copying begins.
//
// Exceptions:
// System.ArgumentNullException:
// array is null.
//
// System.ArgumentOutOfRangeException:
// index is less than zero.
//
// System.ArgumentException:
// array is multidimensional.-or- The number of elements in the source System.Collections.ICollection
// is greater than the available space from index to the end of the destination
// array.-or-The type of the source System.Collections.ICollection cannot be
// cast automatically to the type of the destination array.
void CopyTo(Array array, int index);
}
view raw ICollection.cs hosted with ❤ by GitHub
ICollection<T> Interface
// Summary:
// Defines methods to manipulate generic collections.
//
// Type parameters:
// T:
// The type of the elements in the collection.
public interface ICollection<T> : IEnumerable<T>, IEnumerable
{
// Summary:
// Gets the number of elements contained in the System.Collections.Generic.ICollection<T>.
//
// Returns:
// The number of elements contained in the System.Collections.Generic.ICollection<T>.
int Count { get; }
//
// Summary:
// Gets a value indicating whether the System.Collections.Generic.ICollection<T>
// is read-only.
//
// Returns:
// true if the System.Collections.Generic.ICollection<T> is read-only; otherwise,
// false.
bool IsReadOnly { get; }
// Summary:
// Adds an item to the System.Collections.Generic.ICollection<T>.
//
// Parameters:
// item:
// The object to add to the System.Collections.Generic.ICollection<T>.
//
// Exceptions:
// System.NotSupportedException:
// The System.Collections.Generic.ICollection<T> is read-only.
void Add(T item);
//
// Summary:
// Removes all items from the System.Collections.Generic.ICollection<T>.
//
// Exceptions:
// System.NotSupportedException:
// The System.Collections.Generic.ICollection<T> is read-only.
void Clear();
//
// Summary:
// Determines whether the System.Collections.Generic.ICollection<T> contains
// a specific value.
//
// Parameters:
// item:
// The object to locate in the System.Collections.Generic.ICollection<T>.
//
// Returns:
// true if item is found in the System.Collections.Generic.ICollection<T>; otherwise,
// false.
bool Contains(T item);
//
// Summary:
// Copies the elements of the System.Collections.Generic.ICollection<T> to an
// System.Array, starting at a particular System.Array index.
//
// Parameters:
// array:
// The one-dimensional System.Array that is the destination of the elements
// copied from System.Collections.Generic.ICollection<T>. The System.Array must
// have zero-based indexing.
//
// arrayIndex:
// The zero-based index in array at which copying begins.
//
// Exceptions:
// System.ArgumentNullException:
// array is null.
//
// System.ArgumentOutOfRangeException:
// arrayIndex is less than 0.
//
// System.ArgumentException:
// The number of elements in the source System.Collections.Generic.ICollection<T>
// is greater than the available space from arrayIndex to the end of the destination
// array.
void CopyTo(T[] array, int arrayIndex);
//
// Summary:
// Removes the first occurrence of a specific object from the System.Collections.Generic.ICollection<T>.
//
// Parameters:
// item:
// The object to remove from the System.Collections.Generic.ICollection<T>.
//
// Returns:
// true if item was successfully removed from the System.Collections.Generic.ICollection<T>;
// otherwise, false. This method also returns false if item is not found in
// the original System.Collections.Generic.ICollection<T>.
//
// Exceptions:
// System.NotSupportedException:
// The System.Collections.Generic.ICollection<T> is read-only.
bool Remove(T item);
}
view raw ICollectionT.cs hosted with ❤ by GitHub
IReadOnlyCollection<T> Interface
// Summary:
// Represents a strongly-typed, read-only collection of elements.
//
// Type parameters:
// T:
// The type of the elements.This type parameter is covariant. That is, you can
// use either the type you specified or any type that is more derived. For more
// information about covariance and contravariance, see Covariance and Contravariance
// in Generics.
public interface IReadOnlyCollection<out T> : IEnumerable<T>, IEnumerable
{
// Summary:
// Gets the number of elements in the collection.
//
// Returns:
// The number of elements in the collection.
int Count { get; }
}


IList – Modifiable Collection with Integer Index
Represent a collection of objects than can be individually accessed by index and because of the integer index, IList behaves more like an array rather than a list.

IList Interface
// Summary:
// Represents a non-generic collection of objects that can be individually accessed
// by index.
public interface IList : ICollection, IEnumerable
{
// Summary:
// Gets a value indicating whether the System.Collections.IList has a fixed
// size.
//
// Returns:
// true if the System.Collections.IList has a fixed size; otherwise, false.
bool IsFixedSize { get; }
//
// Summary:
// Gets a value indicating whether the System.Collections.IList is read-only.
//
// Returns:
// true if the System.Collections.IList is read-only; otherwise, false.
bool IsReadOnly { get; }
// Summary:
// Gets or sets the element at the specified index.
//
// Parameters:
// index:
// The zero-based index of the element to get or set.
//
// Returns:
// The element at the specified index.
//
// Exceptions:
// System.ArgumentOutOfRangeException:
// index is not a valid index in the System.Collections.IList.
//
// System.NotSupportedException:
// The property is set and the System.Collections.IList is read-only.
object this[int index] { get; set; }
// Summary:
// Adds an item to the System.Collections.IList.
//
// Parameters:
// value:
// The object to add to the System.Collections.IList.
//
// Returns:
// The position into which the new element was inserted, or -1 to indicate that
// the item was not inserted into the collection,
//
// Exceptions:
// System.NotSupportedException:
// The System.Collections.IList is read-only.-or- The System.Collections.IList
// has a fixed size.
int Add(object value);
//
// Summary:
// Removes all items from the System.Collections.IList.
//
// Exceptions:
// System.NotSupportedException:
// The System.Collections.IList is read-only.
void Clear();
//
// Summary:
// Determines whether the System.Collections.IList contains a specific value.
//
// Parameters:
// value:
// The object to locate in the System.Collections.IList.
//
// Returns:
// true if the System.Object is found in the System.Collections.IList; otherwise,
// false.
bool Contains(object value);
//
// Summary:
// Determines the index of a specific item in the System.Collections.IList.
//
// Parameters:
// value:
// The object to locate in the System.Collections.IList.
//
// Returns:
// The index of value if found in the list; otherwise, -1.
int IndexOf(object value);
//
// Summary:
// Inserts an item to the System.Collections.IList at the specified index.
//
// Parameters:
// index:
// The zero-based index at which value should be inserted.
//
// value:
// The object to insert into the System.Collections.IList.
//
// Exceptions:
// System.ArgumentOutOfRangeException:
// index is not a valid index in the System.Collections.IList.
//
// System.NotSupportedException:
// The System.Collections.IList is read-only.-or- The System.Collections.IList
// has a fixed size.
//
// System.NullReferenceException:
// value is null reference in the System.Collections.IList.
void Insert(int index, object value);
//
// Summary:
// Removes the first occurrence of a specific object from the System.Collections.IList.
//
// Parameters:
// value:
// The object to remove from the System.Collections.IList.
//
// Exceptions:
// System.NotSupportedException:
// The System.Collections.IList is read-only.-or- The System.Collections.IList
// has a fixed size.
void Remove(object value);
//
// Summary:
// Removes the System.Collections.IList item at the specified index.
//
// Parameters:
// index:
// The zero-based index of the item to remove.
//
// Exceptions:
// System.ArgumentOutOfRangeException:
// index is not a valid index in the System.Collections.IList.
//
// System.NotSupportedException:
// The System.Collections.IList is read-only.-or- The System.Collections.IList
// has a fixed size.
void RemoveAt(int index);
}
view raw IList.cs hosted with ❤ by GitHub
IList<T> Interface
// Summary:
// Represents a collection of objects that can be individually accessed by index.
//
// Type parameters:
// T:
// The type of elements in the list.
public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable
{
// Summary:
// Gets or sets the element at the specified index.
//
// Parameters:
// index:
// The zero-based index of the element to get or set.
//
// Returns:
// The element at the specified index.
//
// Exceptions:
// System.ArgumentOutOfRangeException:
// index is not a valid index in the System.Collections.Generic.IList<T>.
//
// System.NotSupportedException:
// The property is set and the System.Collections.Generic.IList<T> is read-only.
T this[int index] { get; set; }
// Summary:
// Determines the index of a specific item in the System.Collections.Generic.IList<T>.
//
// Parameters:
// item:
// The object to locate in the System.Collections.Generic.IList<T>.
//
// Returns:
// The index of item if found in the list; otherwise, -1.
int IndexOf(T item);
//
// Summary:
// Inserts an item to the System.Collections.Generic.IList<T> at the specified
// index.
//
// Parameters:
// index:
// The zero-based index at which item should be inserted.
//
// item:
// The object to insert into the System.Collections.Generic.IList<T>.
//
// Exceptions:
// System.ArgumentOutOfRangeException:
// index is not a valid index in the System.Collections.Generic.IList<T>.
//
// System.NotSupportedException:
// The System.Collections.Generic.IList<T> is read-only.
void Insert(int index, T item);
//
// Summary:
// Removes the System.Collections.Generic.IList<T> item at the specified index.
//
// Parameters:
// index:
// The zero-based index of the item to remove.
//
// Exceptions:
// System.ArgumentOutOfRangeException:
// index is not a valid index in the System.Collections.Generic.IList<T>.
//
// System.NotSupportedException:
// The System.Collections.Generic.IList<T> is read-only.
void RemoveAt(int index);
}
view raw IListT.cs hosted with ❤ by GitHub
IReadOnlyList<T> Interface
// Summary:
// Represents a read-only collection of elements that can be accessed by index.
//
// Type parameters:
// T:
// The type of elements in the read-only list. This type parameter is covariant.
// That is, you can use either the type you specified or any type that is more
// derived. For more information about covariance and contravariance, see Covariance
// and Contravariance in Generics.
public interface IReadOnlyList<out T> : IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
{
// Summary:
// Gets the element at the specified index in the read-only list.
//
// Parameters:
// index:
// The zero-based index of the element to get.
//
// Returns:
// The element at the specified index in the read-only list.
T this[int index] { get; }
}


ISet
ISet Provides the base interface for the abstraction of sets.

ISet<T> Interface
// Summary:
// Provides the base interface for the abstraction of sets.
//
// Type parameters:
// T:
// The type of elements in the set.
public interface ISet<T> : ICollection<T>, IEnumerable<T>, IEnumerable
{
// Summary:
// Adds an element to the current set and returns a value to indicate if the
// element was successfully added.
//
// Parameters:
// item:
// The element to add to the set.
//
// Returns:
// true if the element is added to the set; false if the element is already
// in the set.
bool Add(T item);
//
// Summary:
// Removes all elements in the specified collection from the current set.
//
// Parameters:
// other:
// The collection of items to remove from the set.
//
// Exceptions:
// System.ArgumentNullException:
// other is null.
void ExceptWith(IEnumerable<T> other);
//
// Summary:
// Modifies the current set so that it contains only elements that are also
// in a specified collection.
//
// Parameters:
// other:
// The collection to compare to the current set.
//
// Exceptions:
// System.ArgumentNullException:
// other is null.
void IntersectWith(IEnumerable<T> other);
//
// Summary:
// Determines whether the current set is a proper (strict) subset of a specified
// collection.
//
// Parameters:
// other:
// The collection to compare to the current set.
//
// Returns:
// true if the current set is a proper subset of other; otherwise, false.
//
// Exceptions:
// System.ArgumentNullException:
// other is null.
bool IsProperSubsetOf(IEnumerable<T> other);
//
// Summary:
// Determines whether the current set is a proper (strict) superset of a specified
// collection.
//
// Parameters:
// other:
// The collection to compare to the current set.
//
// Returns:
// true if the current set is a proper superset of other; otherwise, false.
//
// Exceptions:
// System.ArgumentNullException:
// other is null.
bool IsProperSupersetOf(IEnumerable<T> other);
//
// Summary:
// Determines whether a set is a subset of a specified collection.
//
// Parameters:
// other:
// The collection to compare to the current set.
//
// Returns:
// true if the current set is a subset of other; otherwise, false.
//
// Exceptions:
// System.ArgumentNullException:
// other is null.
bool IsSubsetOf(IEnumerable<T> other);
//
// Summary:
// Determines whether the current set is a superset of a specified collection.
//
// Parameters:
// other:
// The collection to compare to the current set.
//
// Returns:
// true if the current set is a superset of other; otherwise, false.
//
// Exceptions:
// System.ArgumentNullException:
// other is null.
bool IsSupersetOf(IEnumerable<T> other);
//
// Summary:
// Determines whether the current set overlaps with the specified collection.
//
// Parameters:
// other:
// The collection to compare to the current set.
//
// Returns:
// true if the current set and other share at least one common element; otherwise,
// false.
//
// Exceptions:
// System.ArgumentNullException:
// other is null.
bool Overlaps(IEnumerable<T> other);
//
// Summary:
// Determines whether the current set and the specified collection contain the
// same elements.
//
// Parameters:
// other:
// The collection to compare to the current set.
//
// Returns:
// true if the current set is equal to other; otherwise, false.
//
// Exceptions:
// System.ArgumentNullException:
// other is null.
bool SetEquals(IEnumerable<T> other);
//
// Summary:
// Modifies the current set so that it contains only elements that are present
// either in the current set or in the specified collection, but not both.
//
// Parameters:
// other:
// The collection to compare to the current set.
//
// Exceptions:
// System.ArgumentNullException:
// other is null.
void SymmetricExceptWith(IEnumerable<T> other);
//
// Summary:
// Modifies the current set so that it contains all elements that are present
// in either the current set or the specified collection.
//
// Parameters:
// other:
// The collection to compare to the current set.
//
// Exceptions:
// System.ArgumentNullException:
// other is null.
void UnionWith(IEnumerable<T> other);
}
view raw ISet.cs hosted with ❤ by GitHub


IDictionary – Associate Container
IDictionary defines an associative container that stores key and value pairs. The interface is relatively straightforward. IDictionaryEnumerator is a helper interface that derives from IEnumerator.


DictionaryEntry Class
// Summary:
// Defines a dictionary key/value pair that can be set or retrieved.
[Serializable]
public struct DictionaryEntry
{
// Summary:
// Initializes an instance of the System.Collections.DictionaryEntry type with
// the specified key and value.
//
// Parameters:
// key:
// The object defined in each key/value pair.
//
// value:
// The definition associated with key.
//
// Exceptions:
// System.ArgumentNullException:
// key is null and the .NET Framework version is 1.0 or 1.1.
public DictionaryEntry(object key, object value);
// Summary:
// Gets or sets the key in the key/value pair.
//
// Returns:
// The key in the key/value pair.
public object Key { get; set; }
//
// Summary:
// Gets or sets the value in the key/value pair.
//
// Returns:
// The value in the key/value pair.
public object Value { get; set; }
}
IDictionaryEnumerator Interface
// Summary:
// Enumerates the elements of a nongeneric dictionary.
public interface IDictionaryEnumerator : IEnumerator
{
// Summary:
// Gets both the key and the value of the current dictionary entry.
//
// Returns:
// A System.Collections.DictionaryEntry containing both the key and the value
// of the current dictionary entry.
//
// Exceptions:
// System.InvalidOperationException:
// The System.Collections.IDictionaryEnumerator is positioned before the first
// entry of the dictionary or after the last entry.
DictionaryEntry Entry { get; }
//
// Summary:
// Gets the key of the current dictionary entry.
//
// Returns:
// The key of the current element of the enumeration.
//
// Exceptions:
// System.InvalidOperationException:
// The System.Collections.IDictionaryEnumerator is positioned before the first
// entry of the dictionary or after the last entry.
object Key { get; }
//
// Summary:
// Gets the value of the current dictionary entry.
//
// Returns:
// The value of the current element of the enumeration.
//
// Exceptions:
// System.InvalidOperationException:
// The System.Collections.IDictionaryEnumerator is positioned before the first
// entry of the dictionary or after the last entry.
object Value { get; }
}
IDictionary Interface
// Summary:
// Represents a nongeneric collection of key/value pairs.
public interface IDictionary : ICollection, IEnumerable
{
// Summary:
// Gets a value indicating whether the System.Collections.IDictionary object
// has a fixed size.
//
// Returns:
// true if the System.Collections.IDictionary object has a fixed size; otherwise,
// false.
bool IsFixedSize { get; }
//
// Summary:
// Gets a value indicating whether the System.Collections.IDictionary object
// is read-only.
//
// Returns:
// true if the System.Collections.IDictionary object is read-only; otherwise,
// false.
bool IsReadOnly { get; }
//
// Summary:
// Gets an System.Collections.ICollection object containing the keys of the
// System.Collections.IDictionary object.
//
// Returns:
// An System.Collections.ICollection object containing the keys of the System.Collections.IDictionary
// object.
ICollection Keys { get; }
//
// Summary:
// Gets an System.Collections.ICollection object containing the values in the
// System.Collections.IDictionary object.
//
// Returns:
// An System.Collections.ICollection object containing the values in the System.Collections.IDictionary
// object.
ICollection Values { get; }
// Summary:
// Gets or sets the element with the specified key.
//
// Parameters:
// key:
// The key of the element to get or set.
//
// Returns:
// The element with the specified key, or null if the key does not exist.
//
// Exceptions:
// System.ArgumentNullException:
// key is null.
//
// System.NotSupportedException:
// The property is set and the System.Collections.IDictionary object is read-only.-or-
// The property is set, key does not exist in the collection, and the System.Collections.IDictionary
// has a fixed size.
object this[object key] { get; set; }
// Summary:
// Adds an element with the provided key and value to the System.Collections.IDictionary
// object.
//
// Parameters:
// key:
// The System.Object to use as the key of the element to add.
//
// value:
// The System.Object to use as the value of the element to add.
//
// Exceptions:
// System.ArgumentNullException:
// key is null.
//
// System.ArgumentException:
// An element with the same key already exists in the System.Collections.IDictionary
// object.
//
// System.NotSupportedException:
// The System.Collections.IDictionary is read-only.-or- The System.Collections.IDictionary
// has a fixed size.
void Add(object key, object value);
//
// Summary:
// Removes all elements from the System.Collections.IDictionary object.
//
// Exceptions:
// System.NotSupportedException:
// The System.Collections.IDictionary object is read-only.
void Clear();
//
// Summary:
// Determines whether the System.Collections.IDictionary object contains an
// element with the specified key.
//
// Parameters:
// key:
// The key to locate in the System.Collections.IDictionary object.
//
// Returns:
// true if the System.Collections.IDictionary contains an element with the key;
// otherwise, false.
//
// Exceptions:
// System.ArgumentNullException:
// key is null.
bool Contains(object key);
//
// Summary:
// Returns an System.Collections.IDictionaryEnumerator object for the System.Collections.IDictionary
// object.
//
// Returns:
// An System.Collections.IDictionaryEnumerator object for the System.Collections.IDictionary
// object.
IDictionaryEnumerator GetEnumerator();
//
// Summary:
// Removes the element with the specified key from the System.Collections.IDictionary
// object.
//
// Parameters:
// key:
// The key of the element to remove.
//
// Exceptions:
// System.ArgumentNullException:
// key is null.
//
// System.NotSupportedException:
// The System.Collections.IDictionary object is read-only.-or- The System.Collections.IDictionary
// has a fixed size.
void Remove(object key);
}
view raw IDictionary.cs hosted with ❤ by GitHub
IDictionary<T> Interface
// Summary:
// Represents a generic collection of key/value pairs.
//
// Type parameters:
// TKey:
// The type of keys in the dictionary.
//
// TValue:
// The type of values in the dictionary.
public interface IDictionary<TKey, TValue> : ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable
{
// Summary:
// Gets an System.Collections.Generic.ICollection<T> containing the keys of
// the System.Collections.Generic.IDictionary<TKey,TValue>.
//
// Returns:
// An System.Collections.Generic.ICollection<T> containing the keys of the object
// that implements System.Collections.Generic.IDictionary<TKey,TValue>.
ICollection<TKey> Keys { get; }
//
// Summary:
// Gets an System.Collections.Generic.ICollection<T> containing the values in
// the System.Collections.Generic.IDictionary<TKey,TValue>.
//
// Returns:
// An System.Collections.Generic.ICollection<T> containing the values in the
// object that implements System.Collections.Generic.IDictionary<TKey,TValue>.
ICollection<TValue> Values { get; }
// Summary:
// Gets or sets the element with the specified key.
//
// Parameters:
// key:
// The key of the element to get or set.
//
// Returns:
// The element with the specified key.
//
// Exceptions:
// System.ArgumentNullException:
// key is null.
//
// System.Collections.Generic.KeyNotFoundException:
// The property is retrieved and key is not found.
//
// System.NotSupportedException:
// The property is set and the System.Collections.Generic.IDictionary<TKey,TValue>
// is read-only.
TValue this[TKey key] { get; set; }
// Summary:
// Adds an element with the provided key and value to the System.Collections.Generic.IDictionary<TKey,TValue>.
//
// Parameters:
// key:
// The object to use as the key of the element to add.
//
// value:
// The object to use as the value of the element to add.
//
// Exceptions:
// System.ArgumentNullException:
// key is null.
//
// System.ArgumentException:
// An element with the same key already exists in the System.Collections.Generic.IDictionary<TKey,TValue>.
//
// System.NotSupportedException:
// The System.Collections.Generic.IDictionary<TKey,TValue> is read-only.
void Add(TKey key, TValue value);
//
// Summary:
// Determines whether the System.Collections.Generic.IDictionary<TKey,TValue>
// contains an element with the specified key.
//
// Parameters:
// key:
// The key to locate in the System.Collections.Generic.IDictionary<TKey,TValue>.
//
// Returns:
// true if the System.Collections.Generic.IDictionary<TKey,TValue> contains
// an element with the key; otherwise, false.
//
// Exceptions:
// System.ArgumentNullException:
// key is null.
bool ContainsKey(TKey key);
//
// Summary:
// Removes the element with the specified key from the System.Collections.Generic.IDictionary<TKey,TValue>.
//
// Parameters:
// key:
// The key of the element to remove.
//
// Returns:
// true if the element is successfully removed; otherwise, false. This method
// also returns false if key was not found in the original System.Collections.Generic.IDictionary<TKey,TValue>.
//
// Exceptions:
// System.ArgumentNullException:
// key is null.
//
// System.NotSupportedException:
// The System.Collections.Generic.IDictionary<TKey,TValue> is read-only.
bool Remove(TKey key);
//
// Summary:
// Gets the value associated with the specified key.
//
// Parameters:
// key:
// The key whose value to get.
//
// value:
// When this method returns, the value associated with the specified key, if
// the key is found; otherwise, the default value for the type of the value
// parameter. This parameter is passed uninitialized.
//
// Returns:
// true if the object that implements System.Collections.Generic.IDictionary<TKey,TValue>
// contains an element with the specified key; otherwise, false.
//
// Exceptions:
// System.ArgumentNullException:
// key is null.
bool TryGetValue(TKey key, out TValue value);
}
view raw IDictionaryT.cs hosted with ❤ by GitHub
IReadOnlyDictionary<T> Interface
// Summary:
// Represents a generic read-only collection of key/value pairs.
//
// Type parameters:
// TKey:
// The type of keys in the read-only dictionary.
//
// TValue:
// The type of values in the read-only dictionary.
public interface IReadOnlyDictionary<TKey, TValue> : IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable
{
// Summary:
// Gets an enumerable collection that contains the keys in the read-only dictionary.
//
// Returns:
// An enumerable collection that contains the keys in the read-only dictionary.
IEnumerable<TKey> Keys { get; }
//
// Summary:
// Gets an enumerable collection that contains the values in the read-only dictionary.
//
// Returns:
// An enumerable collection that contains the values in the read-only dictionary.
IEnumerable<TValue> Values { get; }
// Summary:
// Gets the element that has the specified key in the read-only dictionary.
//
// Parameters:
// key:
// The key to locate.
//
// Returns:
// The element that has the specified key in the read-only dictionary.
//
// Exceptions:
// System.ArgumentNullException:
// key is null.
//
// System.Collections.Generic.KeyNotFoundException:
// The property is retrieved and key is not found.
TValue this[TKey key] { get; }
// Summary:
// Determines whether the read-only dictionary contains an element that has
// the specified key.
//
// Parameters:
// key:
// The key to locate.
//
// Returns:
// true if the read-only dictionary contains an element that has the specified
// key; otherwise, false.
//
// Exceptions:
// System.ArgumentNullException:
// key is null.
bool ContainsKey(TKey key);
//
// Summary:
// Gets the value that is associated with the specified key.
//
// Parameters:
// key:
// The key to locate.
//
// value:
// When this method returns, the value associated with the specified key, if
// the key is found; otherwise, the default value for the type of the value
// parameter. This parameter is passed uninitialized.
//
// Returns:
// true if the object that implements the System.Collections.Generic.IReadOnlyDictionary<TKey,TValue>
// interface contains an element that has the specified key; otherwise, false.
//
// Exceptions:
// System.ArgumentNullException:
// key is null.
bool TryGetValue(TKey key, out TValue value);
}


IComparer, IComparable,  IEquatable<T>, IEqualityComparer
IComparer defines a method, int Compare(object x, object y), that a type implements to compare two objects whereas IComparable defines a generalized type-specific comparison method, int CompareTo(object obj), that a value type or class implements to order or sort its instance.
IEquatable defines a generalized method, Equals(T other), that a value or class implements to create a type-specific method for determining equality of instances. IEqualityComparer defines methods, bool Equals(object x, object y), int GetHashCode(object obj) to support the comparison of objects for equality.

IComparer Interface
// Summary:
// Exposes a method that compares two objects.
public interface IComparer
{
// Summary:
// Compares two objects and returns a value indicating whether one is less than,
// equal to, or greater than the other.
//
// Parameters:
// x:
// The first object to compare.
//
// y:
// The second object to compare.
//
// Returns:
// A signed integer that indicates the relative values of x and y, as shown
// in the following table.Value Meaning Less than zero x is less than y. Zero
// x equals y. Greater than zero x is greater than y.
//
// Exceptions:
// System.ArgumentException:
// Neither x nor y implements the System.IComparable interface.-or- x and y
// are of different types and neither one can handle comparisons with the other.
int Compare(object x, object y);
}
view raw IComparer.cs hosted with ❤ by GitHub
IComparer<T> Interface
// Summary:
// Defines a method that a type implements to compare two objects.
//
// Type parameters:
// T:
// The type of objects to compare.This type parameter is contravariant. That
// is, you can use either the type you specified or any type that is less derived.
// For more information about covariance and contravariance, see Covariance
// and Contravariance in Generics.
public interface IComparer<in T>
{
// Summary:
// Compares two objects and returns a value indicating whether one is less than,
// equal to, or greater than the other.
//
// Parameters:
// x:
// The first object to compare.
//
// y:
// The second object to compare.
//
// Returns:
// A signed integer that indicates the relative values of x and y, as shown
// in the following table.Value Meaning Less than zerox is less than y.Zerox
// equals y.Greater than zerox is greater than y.
int Compare(T x, T y);
}
view raw IComparerT.cs hosted with ❤ by GitHub
IComparable Interface
// Summary:
// Defines a generalized type-specific comparison method that a value type or
// class implements to order or sort its instances.
public interface IComparable
{
// Summary:
// Compares the current instance with another object of the same type and returns
// an integer that indicates whether the current instance precedes, follows,
// or occurs in the same position in the sort order as the other object.
//
// Parameters:
// obj:
// An object to compare with this instance.
//
// Returns:
// A value that indicates the relative order of the objects being compared.
// The return value has these meanings: Value Meaning Less than zero This instance
// precedes obj in the sort order. Zero This instance occurs in the same position
// in the sort order as obj. Greater than zero This instance follows obj in
// the sort order.
//
// Exceptions:
// System.ArgumentException:
// obj is not the same type as this instance.
int CompareTo(object obj);
}
view raw IComparable.cs hosted with ❤ by GitHub
IComparable<T> Interface
// Summary:
// Defines a generalized comparison method that a value type or class implements
// to create a type-specific comparison method for ordering instances.
//
// Type parameters:
// T:
// The type of objects to compare.This type parameter is contravariant. That
// is, you can use either the type you specified or any type that is less derived.
// For more information about covariance and contravariance, see Covariance
// and Contravariance in Generics.
public interface IComparable<in T>
{
// Summary:
// Compares the current object with another object of the same type.
//
// Parameters:
// other:
// An object to compare with this object.
//
// Returns:
// A value that indicates the relative order of the objects being compared.
// The return value has the following meanings: Value Meaning Less than zero
// This object is less than the other parameter.Zero This object is equal to
// other. Greater than zero This object is greater than other.
int CompareTo(T other);
}
view raw IComparableT.cs hosted with ❤ by GitHub

IEquatable<T> Interface
// Summary:
// Defines a generalized method that a value type or class implements to create
// a type-specific method for determining equality of instances.
//
// Type parameters:
// T:
// The type of objects to compare.
public interface IEquatable<T>
{
// Summary:
// Indicates whether the current object is equal to another object of the same
// type.
//
// Parameters:
// other:
// An object to compare with this object.
//
// Returns:
// true if the current object is equal to the other parameter; otherwise, false.
bool Equals(T other);
}
view raw IEquatableT.cs hosted with ❤ by GitHub

IEqualityComparer Interface
// Summary:
// Defines methods to support the comparison of objects for equality.
public interface IEqualityComparer
{
// Summary:
// Determines whether the specified objects are equal.
//
// Parameters:
// x:
// The first object to compare.
//
// y:
// The second object to compare.
//
// Returns:
// true if the specified objects are equal; otherwise, false.
//
// Exceptions:
// System.ArgumentException:
// x and y are of different types and neither one can handle comparisons with
// the other.
bool Equals(object x, object y);
//
// Summary:
// Returns a hash code for the specified object.
//
// Parameters:
// obj:
// The System.Object for which a hash code is to be returned.
//
// Returns:
// A hash code for the specified object.
//
// Exceptions:
// System.ArgumentNullException:
// The type of obj is a reference type and obj is null.
int GetHashCode(object obj);
}
IEqualityComparer<T> Interface
// Summary:
// Defines methods to support the comparison of objects for equality.
//
// Type parameters:
// T:
// The type of objects to compare.This type parameter is contravariant. That
// is, you can use either the type you specified or any type that is less derived.
// For more information about covariance and contravariance, see Covariance
// and Contravariance in Generics.
public interface IEqualityComparer<in T>
{
// Summary:
// Determines whether the specified objects are equal.
//
// Parameters:
// x:
// The first object of type T to compare.
//
// y:
// The second object of type T to compare.
//
// Returns:
// true if the specified objects are equal; otherwise, false.
bool Equals(T x, T y);
//
// Summary:
// Returns a hash code for the specified object.
//
// Parameters:
// obj:
// The System.Object for which a hash code is to be returned.
//
// Returns:
// A hash code for the specified object.
//
// Exceptions:
// System.ArgumentNullException:
// The type of obj is a reference type and obj is null.
int GetHashCode(T obj);
}


IStructuralComparable, IStructuralEquatable
IStructuralComparable supports structural comparison of collection objects and IStructuralEquatable defines methods to support the comparison of objects for structural equality.

IStructuralComparable Interface
// Summary:
// Supports the structural comparison of collection objects.
public interface IStructuralComparable
{
// Summary:
// Determines whether the current collection object precedes, occurs in the
// same position as, or follows another object in the sort order.
//
// Parameters:
// other:
// The object to compare with the current instance.
//
// comparer:
// An object that compares members of the current collection object with the
// corresponding members of other.
//
// Returns:
// An integer that indicates the relationship of the current collection object
// to other, as shown in the following table.Return valueDescription-1The current
// instance precedes other.0The current instance and other are equal.1The current
// instance follows other.
//
// Exceptions:
// System.ArgumentException:
// This instance and other are not the same type.
int CompareTo(object other, IComparer comparer);
}
IStructuralEquatable Interface
// Summary:
// Defines methods to support the comparison of objects for structural equality.
public interface IStructuralEquatable
{
// Summary:
// Determines whether an object is structurally equal to the current instance.
//
// Parameters:
// other:
// The object to compare with the current instance.
//
// comparer:
// An object that determines whether the current instance and other are equal.
//
// Returns:
// true if the two objects are equal; otherwise, false.
bool Equals(object other, IEqualityComparer comparer);
//
// Summary:
// Returns a hash code for the current instance.
//
// Parameters:
// comparer:
// An object that computes the hash code of the current object.
//
// Returns:
// The hash code for the current instance.
int GetHashCode(IEqualityComparer comparer);
}


Collection Interfaces


Collection Generic Interfaces

System.Array – Fixed Sized Array
This class is an abstract base class for all built-in C# arrays. It represents an array of fixed size and implements IList interface. This class is interesting, because it is probably the only class in .NET that is both abstract and sealed. Thus, you can neither instantiate it, nor derive from it. Built-in C# arrays derive from it implicitly. You as a mortal user cannot declare your class abstract sealed - this causes a compilation error.
Array class definition
// Summary:
// Provides methods for creating, manipulating, searching, and sorting arrays,
// thereby serving as the base class for all arrays in the common language runtime.
[Serializable]
public abstract class Array : ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
{
//...
}
view raw Array.cs hosted with ❤ by GitHub

ArrayList – Dynamic Array
This class is a dynamic array that implements the IList interface. ArrayList can work as an adapter for arbitrary IList. Such adapters are created via static method ArrayList.Adapter(). This allows to use methods normally not available for IList, such as RemoveRange(), LastIndexOf() or Sort().
ArrayList class definition
// Summary:
// Implements the System.Collections.IList interface using an array whose size
// is dynamically increased as required.
[Serializable]
public class ArrayList : IList, ICollection, IEnumerable, ICloneable
{
// ...
}
view raw ArrayList.cs hosted with ❤ by GitHub

BitArray  – Array of Bits
This class implements a fixed-sized array of Boolean values, or bits. Note that it implements merely an ICollection - not a full IList. Once constructed, the size of the bit array never changes. Besides, it does not implement IList methods such as IndexOf(), Contains(), etc. From the other hand it implements a number of additional, Boolean-specific methods such as And(), Or(), and Xor()
BitArray class definition
// Summary:
// Manages a compact array of bit values, which are represented as Booleans,
// where true indicates that the bit is on (1) and false indicates the bit is
// off (0).
[Serializable]
public sealed class BitArray : ICollection, IEnumerable, ICloneable
{
// ...
}
view raw BitArray.cs hosted with ❤ by GitHub

Hashtable
Hash table is an un-ordered collection of key-value pairs. Key objects must correctly implement Equals() and GetHashCode.
Hashtable class definition
// Summary:
// Represents a collection of key/value pairs that are organized based on the
// hash code of the key.
[Serializable]
public class Hashtable : IDictionary, ICollection, IEnumerable, ISerializable, IDeserializationCallback, ICloneable
{
// ...
}
view raw Hashtable.cs hosted with ❤ by GitHub

HashSet<T>
HashSet represents a set of values. It is based on the model of mathematical sets and provides high-performance set operations similar to accessing the keys of the Dictionary or Hashtable collections. In simple terms, the HashSet class can be thought of as a Dictionary collection without values. It provides many mathematical set operations, such as set addition (unions) and set subtraction. However, a HashSet collection is not sorted and cannot contain duplicate elements. If order or element duplication is more important than performance for your application, consider using the List class together with the Sort method.
HashSet class definition
// Summary:
// Represents a set of values.
//
// Type parameters:
// T:
// The type of elements in the hash set.
[Serializable]
public class HashSet<T> : ISerializable, IDeserializationCallback, ISet<T>, ICollection<T>, IEnumerable<T>, IEnumerable
{
// ...
}
view raw HashSet.cs hosted with ❤ by GitHub

SortedList, SortedDictionary, SortedSet
Sorted list is a sorted collection of key-value pairs. Besides implementing IDictionary interface, it also allows access to its items by integer index via GetByIndex() and SetByIndex() methods.
SortedList, SortedDictionary, SortedSet classes definition
// Summary:
// Represents a collection of key/value pairs that are sorted by the keys and
// are accessible by key and by index.
[Serializable]
public class SortedList : IDictionary, ICollection, IEnumerable, ICloneable
{
// ..
}
view raw SortedList.cs hosted with ❤ by GitHub
// Summary:
// Represents a collection of key/value pairs that are sorted by key based on
// the associated System.Collections.Generic.IComparer<T> implementation.
//
// Type parameters:
// TKey:
// The type of keys in the collection.
//
// TValue:
// The type of values in the collection.
[Serializable]
public class SortedList<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, IEnumerable
{
// ...
}
view raw SortedListT.cs hosted with ❤ by GitHub
// Summary:
// Represents a collection of key/value pairs that are sorted on the key.
//
// Type parameters:
// TKey:
// The type of the keys in the dictionary.
//
// TValue:
// The type of the values in the dictionary.
[Serializable]
public class SortedDictionary<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, IEnumerable
{
// ...
}
// Summary:
// Represents a collection of objects that is maintained in sorted order.
//
// Type parameters:
// T:
// The type of elements in the set.
[Serializable]
public class SortedSet<T> : ISet<T>, ICollection<T>, IEnumerable<T>, ICollection, IEnumerable, ISerializable, IDeserializationCallback
{
// ...
}
view raw SortedSet.cs hosted with ❤ by GitHub

Queue
Queue implements standard collection operations plus Enqueue(), Dequeue() and Peek() methods. Using reflection we can see that internally it uses standard array (object[]) - much like an ArrayList.
Queue class definition
// Summary:
// Represents a first-in, first-out collection of objects.
[Serializable]
public class Queue : ICollection, IEnumerable, ICloneable
{
// ...
}
view raw Queue.cs hosted with ❤ by GitHub
// Summary:
// Represents a first-in, first-out collection of objects.
//
// Type parameters:
// T:
// Specifies the type of elements in the queue.
[Serializable]
public class Queue<T> : IEnumerable<T>, ICollection, IEnumerable
{
// ...
}
view raw QueueT.cs hosted with ❤ by GitHub

Stack
Stack implements standard collection operations plus Push(), Pop() and Peek() methods.
Stack class definition
// Summary:
// Represents a simple last-in-first-out (LIFO) non-generic collection of objects.
[Serializable]
public class Stack : ICollection, IEnumerable, ICloneable
{
// ...
}
view raw Stack.cs hosted with ❤ by GitHub
// Summary:
// Represents a variable size last-in-first-out (LIFO) collection of instances
// of the same arbitrary type.
//
// Type parameters:
// T:
// Specifies the type of elements in the stack.
[Serializable]
public class Stack<T> : IEnumerable<T>, ICollection, IEnumerable
{
// ...
}
view raw StackT.cs hosted with ❤ by GitHub

CollectionBase,  ReadOnlyCollectionBase, DictionaryBase
These abstract classes implement IList. They represent a base for type-safe collections that manipulates concrete types instead of generic object. Internally CollecationBase is a wrapper around ArrayList.
CollectionBase, ReadOnlyCollectionBase classes definition
// Summary:
// Provides the abstract base class for a strongly typed collection.
[Serializable]
public abstract class CollectionBase : IList, ICollection, IEnumerable
{
// ...
}
// Summary:
// Provides the abstract base class for a strongly typed non-generic read-only
// collection.
[Serializable]
public abstract class ReadOnlyCollectionBase : ICollection, IEnumerable
{
// ...
}

DictionaryBase is an abstract base for type safe dictionaries. The idea is similar to CollectionBase. Internally DictionaryBase relies on a Hashtable.
DictionaryBase classes definition
// Summary:
// Provides the abstract base class for a strongly typed collection of key/value
// pairs.
[Serializable]
public abstract class DictionaryBase : IDictionary, ICollection, IEnumerable
{
// ...
}

StringCollection, StringDictionary
StringCollection implements type-safe collection of strings.
StringDictionary Implements string-to-object map. Interestingly enough, this class neither derives from DictionaryBase, nor implements IDictionary.
StringCollection, StringDictionary classes definition
// Summary:
// Represents a collection of strings.
[Serializable]
public class StringCollection : IList, ICollection, IEnumerable
{
}
// Summary:
// Implements a hash table with the key and the value strongly typed to be strings
// rather than objects.
[Serializable]
[DesignerSerializer("System.Diagnostics.Design.StringDictionaryCodeDomSerializer, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.Serialization.CodeDomSerializer, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public class StringDictionary : IEnumerable
{
// ...
}

NameValueCollection
Implements string-to-string map sorted by key.
NameValueCollection class definition
// Summary:
// Provides the abstract base class for a collection of associated System.String
// keys and System.Object values that can be accessed either with the key or
// with the index.
[Serializable]
public abstract class NameObjectCollectionBase : ICollection, IEnumerable, ISerializable, IDeserializationCallback
{
// ...
}
// Summary:
// Represents a collection of associated System.String keys and System.String
// values that can be accessed either with the key or with the index.
[Serializable]
public class NameValueCollection : NameObjectCollectionBase
{
// ...
}

LinkedList
LinkedList represents a doubly linked list and because it is doubly linked, each node points forward to the Next node and backward to the Previous node. It provides separate nodes of type LinkedListNode, so insertion and removal are O(1) operations.
LinkedList class definition
// Summary:
// Represents a node in a System.Collections.Generic.LinkedList<T>. This class
// cannot be inherited.
//
// Type parameters:
// T:
// Specifies the element type of the linked list.
public sealed class LinkedListNode<T>
{
// ...
}
// Summary:
// Represents a doubly linked list.
//
// Type parameters:
// T:
// Specifies the element type of the linked list.
[Serializable]
public class LinkedList<T> : ICollection<T>, IEnumerable<T>, ICollection, IEnumerable, ISerializable, IDeserializationCallback
{
// ...
}
view raw LinkedList.cs hosted with ❤ by GitHub

ListDictionary,  HybridDictionary
ListDictionary implements a dictionary based on a linked list.
ListDictionary class definition
// Summary:
// Implements IDictionary using a singly linked list. Recommended for collections
// that typically include fewer than 10 items.
[Serializable]
public class ListDictionary : IDictionary, ICollection, IEnumerable
{
// ...
}

HybridDictionary implements a dictionary based on a linked list for small sizes (below 10), and on hash table for bigger sizes.
HybridDictionary class definition
// Summary:
// Implements IDictionary by using a System.Collections.Specialized.ListDictionary
// while the collection is small, and then switching to a System.Collections.Hashtable
// when the collection gets large.
[Serializable]
public class HybridDictionary : IDictionary, ICollection, IEnumerable
{
// ...
}

Comments

Popular Posts