SortedDictionary<TKey,TValue>.Values Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient une collection contenant les valeurs dans le 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
Valeur de propriété
Contenant SortedDictionary<TKey,TValue>.ValueCollection les valeurs dans le SortedDictionary<TKey,TValue>.
Exemples
Cet exemple de code montre comment énumérer les valeurs du dictionnaire à l’aide de la Values propriété et comment énumérer les clés et les valeurs dans le dictionnaire.
Cet exemple de code fait partie d’un exemple plus grand fourni pour la SortedDictionary<TKey,TValue> classe.
// 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
Remarques
Les valeurs de la SortedDictionary<TKey,TValue>.ValueCollection propriété sont triées en fonction de la Comparer propriété et sont dans le même ordre que les clés associées dans la SortedDictionary<TKey,TValue>.KeyCollectionKeys propriété retournée.
Le retour SortedDictionary<TKey,TValue>.ValueCollection n’est pas une copie statique ; à la place, le SortedDictionary<TKey,TValue>.ValueCollection fait référence aux valeurs de l’original SortedDictionary<TKey,TValue>. Par conséquent, les modifications apportées à la SortedDictionary<TKey,TValue> continue à être reflétées dans le SortedDictionary<TKey,TValue>.ValueCollection.
L’obtention de la valeur de cette propriété est une opération O(1).