Share via


StringDictionary.Values Properti

Definisi

Mendapatkan kumpulan nilai di 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

Nilai Properti

yang ICollection menyediakan nilai dalam StringDictionary.

Contoh

Contoh kode berikut menghitung elemen dari 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

Keterangan

Urutan nilai dalam ICollection tidak ditentukan, tetapi urutannya sama dengan kunci terkait dalam yang ICollection dikembalikan oleh Keys metode .

yang dikembalikan ICollection bukan salinan statis; sebagai gantinya ICollection , mengacu kembali ke nilai dalam aslinya StringDictionary. Oleh karena itu, perubahan pada StringDictionary terus tercermin dalam ICollection.

Mengambil nilai properti ini adalah operasi O(1).

Berlaku untuk