SortedDictionary.KeyCollection Generic Class
Assembly: System (in system.dll)
'Declaration <SerializableAttribute> _ Public NotInheritable Class KeyCollection Implements ICollection(Of TKey), IEnumerable(Of TKey), _ ICollection, IEnumerable 'Usage Dim instance As KeyCollection
The SortedDictionary.Keys property returns an instance of this type, containing all the keys in that SortedDictionary. The order of the keys in the SortedDictionary.KeyCollection is the same as the order of elements in the SortedDictionary, the same as the order of the associated values in the SortedDictionary.ValueCollection returned by the SortedDictionary.Values property.
The SortedDictionary.KeyCollection is not a static copy; instead, the SortedDictionary.KeyCollection refers back to the keys in the original SortedDictionary. Therefore, changes to the SortedDictionary continue to be reflected in the SortedDictionary.KeyCollection.
Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
A SortedDictionary.KeyCollection 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.
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.