Dictionary.ValueCollection Generic Class (System.Collections.Generic)

Switch View :
ScriptFree
Dictionary.ValueCollection Generic Class
Represents the collection of values in a Dictionary. This class cannot be inherited.

Namespace: System.Collections.Generic
Assembly: mscorlib (in mscorlib.dll)

Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
Public NotInheritable Class ValueCollection
	Implements ICollection(Of TValue), IEnumerable(Of TValue), _
	ICollection, IEnumerable
Visual Basic (Usage)
Dim instance As ValueCollection

C#
[SerializableAttribute] 
public sealed class ValueCollection : ICollection<TValue>, IEnumerable<TValue>, 
	ICollection, IEnumerable
C++
[SerializableAttribute] 
public ref class ValueCollection sealed : ICollection<TValue>, IEnumerable<TValue>, 
	ICollection, IEnumerable
J#
J# supports the use of generic types and methods, but not the declaration of new ones.
JScript
JScript does not support generic types and methods.
XAML
Not applicable.
Remarks

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

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

Inheritance Hierarchy

System.Object
  System.Collections.Generic.Dictionary.ValueCollection
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.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.

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0
See Also