Dictionary<TKey,TValue>.ValueCollection Class

Definition

Represents the collection of values in a Dictionary<TKey,TValue>. This class cannot be inherited.

public: ref class Dictionary<TKey, TValue>::ValueCollection sealed : System::Collections::Generic::ICollection<TValue>, System::Collections::Generic::IEnumerable<TValue>, System::Collections::Generic::IReadOnlyCollection<TValue>, System::Collections::ICollection
[System.Serializable]
public sealed class Dictionary<TKey,TValue>.ValueCollection : System.Collections.Generic.ICollection<TValue>, System.Collections.Generic.IEnumerable<TValue>, System.Collections.Generic.IReadOnlyCollection<TValue>, System.Collections.ICollection
type Dictionary<'Key, 'Value>.ValueCollection = class
    interface ICollection<'Value>
    interface ICollection
    interface IReadOnlyCollection<'Value>
    interface seq<'Value>
    interface IEnumerable
Public NotInheritable Class Dictionary(Of TKey, TValue).ValueCollection
Implements ICollection, ICollection(Of TValue), IEnumerable(Of TValue), IReadOnlyCollection(Of TValue)

Type Parameters

TKey
TValue
Inheritance
Dictionary<TKey,TValue>.ValueCollection
Attributes
Implements

Remarks

The Dictionary<TKey,TValue>.Values property returns an instance of this type, containing all the values in that Dictionary<TKey,TValue>. The order of the values in the Dictionary<TKey,TValue>.ValueCollection is unspecified, but it is the same order as the associated keys in the Dictionary<TKey,TValue>.KeyCollection returned by the Dictionary<TKey,TValue>.Keys property.

The Dictionary<TKey,TValue>.ValueCollection is not a static copy; instead, the Dictionary<TKey,TValue>.ValueCollection refers back to the values in the original Dictionary<TKey,TValue>. Therefore, changes to the Dictionary<TKey,TValue> continue to be reflected in the Dictionary<TKey,TValue>.ValueCollection.

Constructors

Dictionary<TKey,TValue>.ValueCollection(Dictionary<TKey,TValue>)

Initializes a new instance of the Dictionary<TKey,TValue>.ValueCollection class that reflects the values in the specified Dictionary<TKey,TValue>.

Properties

Count

Gets the number of elements contained in the Dictionary<TKey,TValue>.ValueCollection.

Methods

CopyTo(TValue[], Int32)

Copies the Dictionary<TKey,TValue>.ValueCollection elements to an existing one-dimensional Array, starting at the specified array index.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator()

Returns an enumerator that iterates through the Dictionary<TKey,TValue>.ValueCollection.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

ICollection.CopyTo(Array, Int32)

Copies the elements of the ICollection to an Array, starting at a particular Array index.

ICollection.IsSynchronized

Gets a value indicating whether access to the ICollection is synchronized (thread safe).

ICollection.SyncRoot

Gets an object that can be used to synchronize access to the ICollection.

ICollection<TValue>.Add(TValue)

Adds an item to the ICollection<T>. This implementation always throws NotSupportedException.

ICollection<TValue>.Clear()

Removes all items from the ICollection<T>. This implementation always throws NotSupportedException.

ICollection<TValue>.Contains(TValue)

Determines whether the ICollection<T> contains a specific value.

ICollection<TValue>.IsReadOnly

Gets a value indicating whether the ICollection<T> is read-only.

ICollection<TValue>.Remove(TValue)

Removes the first occurrence of a specific object from the ICollection<T>. This implementation always throws NotSupportedException.

IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.

IEnumerable<TValue>.GetEnumerator()

Returns an enumerator that iterates through a collection.

Extension Methods

CopyToDataTable<T>(IEnumerable<T>)

Returns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>)

Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName)

Returns a filtered collection of elements that contains the ancestors of every node in the source collection. Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>)

Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>)

Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName)

Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>)

Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName)

Returns a filtered collection of the child elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>)

Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>)

Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>)

Removes every node in the source collection from its parent node.

Applies to

Thread Safety

Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

A Dictionary<TKey,TValue>.ValueCollection can support multiple readers concurrently, as long as the collection is not modified. Even so, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.