SortedDictionary<TKey,TValue>.Values Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee haalt u een verzameling op met de waarden in de SortedDictionary<TKey,TValue>.
public:
property System::Collections::Generic::SortedDictionary<TKey, TValue>::ValueCollection ^ Values { System::Collections::Generic::SortedDictionary<TKey, TValue>::ValueCollection ^ get(); };
public System.Collections.Generic.SortedDictionary<TKey,TValue>.ValueCollection Values { get; }
member this.Values : System.Collections.Generic.SortedDictionary<'Key, 'Value>.ValueCollection
Public ReadOnly Property Values As SortedDictionary(Of TKey, TValue).ValueCollection
Waarde van eigenschap
Een SortedDictionary<TKey,TValue>.ValueCollection met de waarden in de SortedDictionary<TKey,TValue>.
Voorbeelden
In dit codevoorbeeld ziet u hoe u de waarden in de woordenlijst opsommen met behulp van de Values eigenschap en hoe u de sleutels en waarden in de woordenlijst opsommen.
Dit codevoorbeeld maakt deel uit van een groter voorbeeld voor de SortedDictionary<TKey,TValue> klasse.
// To get the values alone, use the Values property.
SortedDictionary<string, string>.ValueCollection valueColl =
openWith.Values;
// The elements of the ValueCollection are strongly typed
// with the type that was specified for dictionary values.
Console.WriteLine();
foreach( string s in valueColl )
{
Console.WriteLine("Value = {0}", s);
}
' To get the values alone, use the Values property.
Dim valueColl _
As SortedDictionary(Of String, String).ValueCollection = _
openWith.Values
' The elements of the ValueCollection are strongly typed
' with the type that was specified for dictionary values.
Console.WriteLine()
For Each s As String In valueColl
Console.WriteLine("Value = {0}", s)
Next s
// When you use foreach to enumerate dictionary elements,
// the elements are retrieved as KeyValuePair objects.
Console.WriteLine();
foreach( KeyValuePair<string, string> kvp in openWith )
{
Console.WriteLine("Key = {0}, Value = {1}",
kvp.Key, kvp.Value);
}
' When you use foreach to enumerate dictionary elements,
' the elements are retrieved as KeyValuePair objects.
Console.WriteLine()
For Each kvp As KeyValuePair(Of String, String) In openWith
Console.WriteLine("Key = {0}, Value = {1}", _
kvp.Key, kvp.Value)
Next kvp
Opmerkingen
De waarden in de SortedDictionary<TKey,TValue>.ValueCollection eigenschap worden gesorteerd op basis van de Comparer eigenschap en bevinden zich in dezelfde volgorde als de bijbehorende sleutels in de SortedDictionary<TKey,TValue>.KeyCollection geretourneerde Keys eigenschap.
De geretourneerde SortedDictionary<TKey,TValue>.ValueCollection kopie is geen statische kopie. In plaats daarvan verwijst de SortedDictionary<TKey,TValue>.ValueCollection waarde terug naar de waarden in het origineel SortedDictionary<TKey,TValue>. Daarom blijven wijzigingen in de wijzigingen in de SortedDictionary<TKey,TValue>SortedDictionary<TKey,TValue>.ValueCollection.
Het ophalen van de waarde van deze eigenschap is een O(1)-bewerking.