StringDictionary.Values Propriété

Définition

Obtient une collection de valeurs de 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é

ICollection qui fournit les valeurs de StringDictionary.

Exemples

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

#using <System.dll>

using namespace System;
using namespace System::Collections;
using namespace System::Collections::Specialized;

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

        Console::WriteLine("VALUES");
        for each (String^ val in myCol->Values)
        {
            Console::WriteLine(val);
        }
    }
};

int main()
{
    SamplesStringDictionary::Main();
}
// This code produces the following output.
// VALUES
// verde
// rojo
// azul
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 n’est pas spécifié, mais il s’agit du même ordre que les clés associées dans le ICollection retourné par la Keys méthode .

Le retourné ICollection n’est pas une copie statique ; au lieu de cela, le ICollection fait référence aux valeurs de l’original StringDictionary. Par conséquent, les StringDictionary modifications apportées au continuent d’être répercutées dans le ICollection.

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

S’applique à