.NET API Reference

Collections Namespace

Namespace: System.Collections

Assembly: mscorlib.dll

Description: Contains interfaces and classes that define the behavior of collections of objects. This namespace includes non-generic collection types, as well as interfaces for generic collections.

Types in this Namespace

ICollection Interface

Namespace: System.Collections

Assembly: mscorlib.dll

Provides properties and methods for all collection types. This is the base interface for types that represent collections of objects.

public interface ICollection : IEnumerable

Members:

  • Count: Gets the number of elements contained in the ICollection.
  • IsSynchronized: Gets a value indicating whether access to the ICollection is synchronized (thread-safe).
  • SyncRoot: Gets an object that can be used to synchronize access to the ICollection.
  • Add(object value): Adds an item to the end of the ICollection.
  • Clear(): Removes all items from the ICollection.
  • Contains(object value): Determines whether an element is in the ICollection.
  • CopyTo(Array array, int index): Copies the entire ICollection to a compatible one-dimensional Array, starting at the specified index of the target array.
  • GetEnumerator(): Returns an enumerator that iterates through the ICollection.
  • Remove(object value): Removes the first occurrence of a specific object from the ICollection.

ICollection<T> Interface

Namespace: System.Collections.Generic

Assembly: mscorlib.dll

Represents a collection of objects of a specified type. This is the base interface for generic collection types.

public interface ICollection<T> : IEnumerable<T>, IEnumerable

Members:

  • Count: Gets the number of elements contained in the ICollection<T>.
  • Add(T item): Adds an item to the end of the ICollection<T>.
  • Clear(): Removes all items from the ICollection<T>.
  • Contains(T item): Determines whether an item is in the ICollection<T>.
  • CopyTo(T[] array, int arrayIndex): Copies the elements of the ICollection<T> to an Array, starting at a specified array index.
  • IsReadOnly: Gets a value indicating whether the ICollection<T> is read-only.
  • Remove(T item): Removes the first occurrence of a specific item from the ICollection<T>.

IEnumerable Interface

Namespace: System.Collections

Assembly: mscorlib.dll

Exposes an enumerator, which supports a simple iteration over a non-generic collection.

public interface IEnumerable

Members:

  • GetEnumerator(): Returns an enumerator that iterates through a collection.

IEnumerator Interface

Namespace: System.Collections

Assembly: mscorlib.dll

Supports a simple iteration over a non-generic collection.

public interface IEnumerator

Members:

  • Current: Gets the current element in the collection.
  • MoveNext(): Advances the enumerator to the next element of the collection.
  • Reset(): Sets the enumerator to its initial position, which is before the first element in the collection.

IEnumerator<T> Interface

Namespace: System.Collections.Generic

Assembly: mscorlib.dll

Supports a generic iteration over a collection.

public interface IEnumerator<out T> : IDisposable, IEnumerator

Members:

  • Current: Gets the current element in the collection.
  • MoveNext(): Advances the enumerator to the next element of the collection.
  • Reset(): Sets the enumerator to its initial position. (Inherited from IEnumerator)
  • Dispose(): Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

IList Interface

Namespace: System.Collections

Assembly: mscorlib.dll

Represents a non-generic collection of objects that can be individually accessed by index. The list has an ordered collection of items. If the list is resizable, any number of elements can be added or removed from it.

public interface IList : ICollection, IEnumerable

Members:

  • IsFixedSize: Gets a value indicating whether the IList has a fixed size.
  • IsReadOnly: Gets a value indicating whether the IList is read-only.
  • Item(int index): Gets or sets the element at the specified index.
  • Add(object value): Inserts an item into the IList at the specified index.
  • Clear(): Removes all items from the IList.
  • Contains(object value): Determines whether an element is in the IList.
  • IndexOf(object value): Determines the index of a specific item in the IList.
  • Insert(int index, object value): Inserts an item into the IList at the specified index.
  • Remove(object value): Removes the first occurrence of a specific object from the IList.
  • RemoveAt(int index): Removes the element at the specified index of the IList.

IList<T> Interface

Namespace: System.Collections.Generic

Assembly: mscorlib.dll

Represents a strongly typed list of objects that can be individually accessed by index. The list has an ordered collection of items. If the list is resizable, any number of elements can be added or removed from it.

public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable

Members:

  • Item(int index): Gets or sets the element at the specified index.
  • Add(T item): Adds an item to the end of the IList<T>.
  • Clear(): Removes all items from the IList<T>.
  • Contains(T item): Determines whether an item is in the IList<T>.
  • IndexOf(T item): Searches for the specified object and returns the zero-based index of the first occurrence within the entire IList<T>.
  • Insert(int index, T item): Inserts an item into the IList<T> at the specified index.
  • Remove(T item): Removes the first occurrence of a specific item from the IList<T>.
  • RemoveAt(int index): Removes the element at the specified index of the IList<T>.

IDictionary Interface

Namespace: System.Collections

Assembly: mscorlib.dll

Represents a collection of key/value pairs that are not ordered.

public interface IDictionary : ICollection, IEnumerable

Members:

  • IsFixedSize: Gets a value indicating whether the IDictionary has a fixed size.
  • IsReadOnly: Gets a value indicating whether the IDictionary is read-only.
  • Keys: Gets an ICollection containing the keys in the IDictionary.
  • Values: Gets an ICollection containing the values in the IDictionary.
  • Item(object key): Gets or sets the element with the specified key.
  • Add(object key, object value): Adds an element with the specified key and value to the IDictionary.
  • Contains(object key): Determines whether the IDictionary contains an element with the specified key.
  • GetEnumerator(): Returns an IDictionaryEnumerator that iterates through the IDictionary.
  • Remove(object key): Removes the element with the specified key from the IDictionary.

IDictionary<TKey, TValue> Interface

Namespace: System.Collections.Generic

Assembly: mscorlib.dll

Represents a collection of key/value pairs.

public interface IDictionary<TKey, TValue> : ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable

Members:

  • Keys: Gets an ICollection containing the keys in the IDictionary<TKey, TValue>.
  • Values: Gets an ICollection containing the values in the IDictionary<TKey, TValue>.
  • Item(TKey key): Gets or sets the element with the specified key.
  • Add(TKey key, TValue value): Adds an element with the specified key and value to the IDictionary<TKey, TValue>.
  • ContainsKey(TKey key): Determines whether the IDictionary<TKey, TValue> contains an element with the specified key.
  • Remove(TKey key): Removes the element with the specified key from the IDictionary<TKey, TValue>.
  • TryGetValue(TKey key, out TValue value): Gets the value associated with the specified key.

KeyValuePair<TKey, TValue> Struct

Namespace: System.Collections.Generic

Assembly: mscorlib.dll

Represents a value of a specified type that is associated with a specified key. This structure is used by IDictionary<TKey, TValue>.

public struct KeyValuePair<TKey, TValue>

Members:

  • Key: Gets the key of the key/value pair.
  • Value: Gets the value of the key/value pair.

IQueryable Interface

Namespace: System.Linq

Assembly: System.Core.dll

Provides information that allows an application to substitute for the query execution logic. This is the base interface for LINQ queries.

public interface IQueryable : IEnumerable

Members:

  • ElementType: Gets the type of elements in the sequence.
  • Expression: Gets the expression tree that is associated with the data source.
  • Provider: Gets the type of the LINQ provider.
  • GetEnumerator(): Returns an enumerator that iterates through a collection.

IQueryable<T> Interface

Namespace: System.Linq

Assembly: System.Core.dll

Represents a queryable collection of elements of a specified type.

public interface IQueryable<out T> : IQueryable, IEnumerable<T>, IEnumerable

Members:

  • ElementType: Gets the type of elements in the sequence.
  • Expression: Gets the expression tree that is associated with the data source.
  • Provider: Gets the type of the LINQ provider.
  • GetEnumerator(): Returns an enumerator that iterates through a collection.