StringDictionary.Values Propriété

Définition

Obtient une collection de valeurs dans le StringDictionary.

public:
 virtual property System::Collections::ICollection ^ Values { System::Collections::ICollection ^ get(); };
public virtual System.Collections.ICollection Values { get; }
member this.Values : System.Collections.ICollection
Public Overridable ReadOnly Property Values As ICollection

Valeur de propriété

Qui ICollection fournit les valeurs dans le StringDictionary.

Exemples

L’exemple de code suivant énumère les éléments d’un StringDictionary.

using System;
using System.Collections;
using System.Collections.Specialized;

public class SamplesStringDictionary
{
    public static void Main()
    {
        // Creates and initializes a new StringDictionary.
        StringDictionary myCol = new StringDictionary();
        myCol.Add( "red", "rojo" );
        myCol.Add( "green", "verde" );
        myCol.Add( "blue", "azul" );

        Console.WriteLine("VALUES");
        foreach (string val in myCol.Values)
        {
            Console.WriteLine(val);
        }
    }
}
// This code produces the following output.
// VALUES
// verde
// rojo
// azul
Imports System.Collections
Imports System.Collections.Specialized

Public Class SamplesStringDictionary
    Public Shared Sub Main()
        ' Creates and initializes a new StringDictionary.
        Dim myCol As New StringDictionary()
        myCol.Add( "red", "rojo" )
        myCol.Add( "green", "verde" )
        myCol.Add( "blue", "azul" )

        Console.WriteLine("VALUES")
        For Each val As String In myCol.Values
            Console.WriteLine(val)
        Next val
    End Sub
End Class

' This code produces the following output.
'
' VALUES
' verde
' rojo
' azul

Remarques

L’ordre des valeurs dans le ICollection fichier n’est pas spécifié, mais il s’agit de l’ordre des clés associées dans la ICollectionKeys méthode retournée.

Le retour ICollection n’est pas une copie statique ; à la place, le ICollection fait référence aux valeurs de l’original StringDictionary. Par conséquent, les modifications apportées à la StringDictionary continue à être reflétées dans le ICollection.

La récupération de la valeur de cette propriété est une opération O(1).

S’applique à