System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class

public sealed class Dictionary<TKey,TValue>.KeyCollection: ICollection<TKey>, IEnumerable<TKey>, ICollection, IEnumerable

Base Types

Object
  Dictionary<TKey,TValue>.KeyCollection

This type implements ICollection, IEnumerable, System.Collections.Generic.ICollection<TKey>, and System.Collections.Generic.IEnumerable<TKey>.

Assembly

mscorlib

Library

BCL

Summary

Represents a read-only collection of keys in a dictionary.

Description

The System.Collections.Generic.Dictionary<TKey,TValue>.Keys property returns an instance of this type, containing all the keys in that dictionary. The order of the keys in the key collection is unspecified, but it is the same order as the associated values in the value collection returned by the System.Collections.Generic.Dictionary<TKey,TValue>.Values property.

If the underlying dictionary is modified, or the value of any key in that dictionary is modified, the behavior of the key collection is unspecified.

See Also

System.Collections.Generic Namespace

Members

Dictionary<TKey,TValue>.KeyCollection Constructors

Dictionary<TKey,TValue>.KeyCollection Constructor

Dictionary<TKey,TValue>.KeyCollection Methods

Dictionary<TKey,TValue>.KeyCollection.CopyTo Method
Dictionary<TKey,TValue>.KeyCollection.GetEnumerator Method
Dictionary<TKey,TValue>.KeyCollection.System.Collections.Generic.ICollection<TKey>.Add Method
Dictionary<TKey,TValue>.KeyCollection.System.Collections.Generic.ICollection<TKey>.Clear Method
Dictionary<TKey,TValue>.KeyCollection.System.Collections.Generic.ICollection<TKey>.Contains Method
Dictionary<TKey,TValue>.KeyCollection.System.Collections.Generic.ICollection<TKey>.Remove Method
Dictionary<TKey,TValue>.KeyCollection.System.Collections.Generic.IEnumerable<TKey>.GetEnumerator Method
Dictionary<TKey,TValue>.KeyCollection.System.Collections.ICollection.CopyTo Method
Dictionary<TKey,TValue>.KeyCollection.System.Collections.IEnumerable.GetEnumerator Method

Dictionary<TKey,TValue>.KeyCollection Properties

Dictionary<TKey,TValue>.KeyCollection.Count Property
Dictionary<TKey,TValue>.KeyCollection.System.Collections.Generic.ICollection<TKey>.IsReadOnly Property
Dictionary<TKey,TValue>.KeyCollection.System.Collections.ICollection.IsSynchronized Property
Dictionary<TKey,TValue>.KeyCollection.System.Collections.ICollection.SyncRoot Property


Dictionary<TKey,TValue>.KeyCollection Constructor

public KeyCollection(Dictionary<TKey,TValue> dictionary)

Summary

Initializes a new key collection to reflect the keys from the specified dictionary.

Parameters

dictionary
The dictionary whose keys are to be reflected in the key collection.

Exceptions

Exception TypeCondition
ArgumentNullExceptiondictionary is null .

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.CopyTo Method

public void CopyTo(TKey[] array, int arrayIndex)

Summary

Copies the elements of the key collection to a Array, starting at a particular index.

Parameters

array
A one-dimensional, zero-based Array that is the destination of the elements copied from the key collection.
arrayIndex
The zero-based index in array at which copying begins.

Exceptions

Exception TypeCondition
ArgumentExceptionarray is multidimensional.

-or-

array does not have zero-based indexing.

-or-

arrayIndex is greater than the length of array.

-or-

The number of elements in the key collection is greater than the available space from arrayIndex to the end of the destination array.

-or-

Some element of the key collection is not assignable to the element type of the array.

ArgumentNullExceptionarray is null .

ArgumentOutOfRangeExceptionarrayIndex < 0.

Description

The elements are copied onto the array in the same order in which the enumerator iterates through the key collection.

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.GetEnumerator Method

public Dictionary<TKey,TValue>.KeyCollection.Enumerator GetEnumerator()

Summary

Returns an enumerator that can be used to iterate over the key collection.

Return Value

An enumerator for the key collection.

Description

If the underlying dictionary is modified, or the value of any key in that dictionary is modified, the behavior of the enumerator is unspecified.

[Usage: For a detailed description regarding the use of an enumerator, see System.Collections.Generic.IEnumerator<TKey>.]

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.System.Collections.Generic.ICollection<TKey>.Add Method

void ICollection<TKey>.Add(TKey item)

Summary

This method is implemented to support the System.Collections.Generic.ICollection<TKey> interface. This method throws an exception of type NotSupportedException.

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.System.Collections.Generic.ICollection<TKey>.Clear Method

void ICollection<TKey>.Clear()

Summary

This method is implemented to support the System.Collections.Generic.ICollection<TKey> interface. This method throws an exception of type NotSupportedException.

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.System.Collections.Generic.ICollection<TKey>.Contains Method

bool ICollection<TKey>.Contains(TKey item)

Summary

This method is implemented to support the System.Collections.Generic.ICollection<TKey> interface.

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.System.Collections.Generic.ICollection<TKey>.Remove Method

bool ICollection<TKey>.Remove(TKey item)

Summary

This method is implemented to support the System.Collections.Generic.ICollection<TKey> interface. This method throws an exception of type NotSupportedException.

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.System.Collections.Generic.IEnumerable<TKey>.GetEnumerator Method

IEnumerator<TKey> IEnumerable<TKey>.GetEnumerator()

Summary

This method is implemented to support the System.Collections.Generic.IEnumerable<TKey> interface.

Description

If the underlying dictionary is modified, or the value of any key in that dictionary is modified, the behavior of the enumerator is unspecified.

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.System.Collections.ICollection.CopyTo Method

void ICollection.CopyTo(Array array, int index)

Summary

This method is implemented to support the ICollection interface.

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.System.Collections.IEnumerable.GetEnumerator Method

IEnumerator IEnumerable.GetEnumerator()

Summary

This method is implemented to support the IEnumerable interface.

Description

If the underlying dictionary is modified, or the value of any key in that dictionary is modified, the behavior of the enumerator is unspecified.

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.Count Property

public int Count { get; }

Summary

Gets the number of elements contained in the key collection.

Property Value

The number of elements in the key collection.

Description

This property is read-only.

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.System.Collections.Generic.ICollection<TKey>.IsReadOnly Property

bool ICollection<TKey>.IsReadOnly { get; }

Summary

This read-only property is implemented to support the System.Collections.Generic.ICollection<TKey> interface. This property returns true.

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.System.Collections.ICollection.IsSynchronized Property

bool ICollection.IsSynchronized { get; }

Summary

This read-only property is implemented to support the ICollection interface. This property returns false.

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace

Dictionary<TKey,TValue>.KeyCollection.System.Collections.ICollection.SyncRoot Property

object ICollection.SyncRoot { get; }

Summary

This property is implemented to support the ICollection interface.

Description

This read-only property returns the SyncRoot property of the underlying dictionary.

See Also

System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace