public sealed class Dictionary<TKey,TValue>.KeyCollection: ICollection<TKey>, IEnumerable<TKey>, ICollection, IEnumerable
Object
Dictionary<TKey,TValue>.KeyCollectionThis type implements ICollection, IEnumerable, System.Collections.Generic.ICollection<TKey>, and System.Collections.Generic.IEnumerable<TKey>.
mscorlib
BCL
Represents a read-only collection of keys in a dictionary.
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.
System.Collections.Generic Namespace
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
public KeyCollection(Dictionary<TKey,TValue> dictionary)
Initializes a new key collection to reflect the keys from the specified dictionary.
- dictionary
- The dictionary whose keys are to be reflected in the key collection.
Exception Type Condition ArgumentNullException dictionary is null
.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
public void CopyTo(TKey[] array, int arrayIndex)
Copies the elements of the key collection to a Array, starting at a particular index.
- 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.
Exception Type Condition ArgumentException array 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.
ArgumentNullException array is null
.
ArgumentOutOfRangeException arrayIndex < 0.
The elements are copied onto the array in the same order in which the enumerator iterates through the key collection.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
public Dictionary<TKey,TValue>.KeyCollection.Enumerator GetEnumerator()
Returns an enumerator that can be used to iterate over the key collection.
An enumerator for the key collection.
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>.]
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
void ICollection<TKey>.Add(TKey item)
This method is implemented to support the System.Collections.Generic.ICollection<TKey> interface. This method throws an exception of type NotSupportedException.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
void ICollection<TKey>.Clear()
This method is implemented to support the System.Collections.Generic.ICollection<TKey> interface. This method throws an exception of type NotSupportedException.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
bool ICollection<TKey>.Contains(TKey item)
This method is implemented to support the System.Collections.Generic.ICollection<TKey> interface.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
bool ICollection<TKey>.Remove(TKey item)
This method is implemented to support the System.Collections.Generic.ICollection<TKey> interface. This method throws an exception of type NotSupportedException.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
IEnumerator<TKey> IEnumerable<TKey>.GetEnumerator()
This method is implemented to support the System.Collections.Generic.IEnumerable<TKey> interface.
If the underlying dictionary is modified, or the value of any key in that dictionary is modified, the behavior of the enumerator is unspecified.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
void ICollection.CopyTo(Array array, int index)
This method is implemented to support the ICollection interface.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
IEnumerator IEnumerable.GetEnumerator()
This method is implemented to support the IEnumerable interface.
If the underlying dictionary is modified, or the value of any key in that dictionary is modified, the behavior of the enumerator is unspecified.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
public int Count { get; }
Gets the number of elements contained in the key collection.
The number of elements in the key collection.
This property is read-only.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
bool ICollection<TKey>.IsReadOnly { get; }
This read-only property is implemented to support the System.Collections.Generic.ICollection<TKey> interface. This property returns true.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
bool ICollection.IsSynchronized { get; }
This read-only property is implemented to support the ICollection interface. This property returns false.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace
object ICollection.SyncRoot { get; }
This property is implemented to support the ICollection interface.
This read-only property returns theSyncRoot
property of the underlying dictionary.
System.Collections.Generic.Dictionary<TKey,TValue>.KeyCollection Class, System.Collections.Generic Namespace