OrderedDictionary::Values Property
Gets an ICollection object containing the values in the OrderedDictionary collection.
Assembly: System (in System.dll)
Property Value
Type: System.Collections::ICollectionAn ICollection object containing the values in the OrderedDictionary collection.
Implements
IDictionary::ValuesThe returned ICollection object is not a static copy; instead, the ICollection refers back to the values in the original OrderedDictionary collection. Therefore, changes to the OrderedDictionary continue to be reflected in the ICollection.
The following code example demonstrates the creation and population of an OrderedDictionary collection, and then prints the contents to the console. In this example, the Keys and Values properties are passed to a method that displays the contents. This code is part of a larger code example that can be viewed at OrderedDictionary.
// Creates and initializes a OrderedDictionary. OrderedDictionary^ myOrderedDictionary = gcnew OrderedDictionary(); myOrderedDictionary->Add("testKey1", "testValue1"); myOrderedDictionary->Add("testKey2", "testValue2"); myOrderedDictionary->Add("keyToDelete", "valueToDelete"); myOrderedDictionary->Add("testKey3", "testValue3"); ICollection^ keyCollection = myOrderedDictionary->Keys; ICollection^ valueCollection = myOrderedDictionary->Values; // Display the contents using the key and value collections DisplayContents(keyCollection, valueCollection, myOrderedDictionary->Count);
// Displays the contents of the OrderedDictionary from its keys and values static void DisplayContents( ICollection^ keyCollection, ICollection^ valueCollection, int dictionarySize) { array<String^>^ myKeys = gcnew array<String^>(dictionarySize); array<String^>^ myValues = gcnew array<String^>(dictionarySize); keyCollection->CopyTo(myKeys, 0); valueCollection->CopyTo(myValues, 0); // Displays the contents of the OrderedDictionary Console::WriteLine(" INDEX KEY VALUE"); for (int i = 0; i < dictionarySize; i++) { Console::WriteLine(" {0,-5} {1,-25} {2}", i, myKeys[i], myValues[i]); } Console::WriteLine(); }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.