StringDictionary.Values Vlastnost

Definice

Získá kolekci hodnot v objektu 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

Hodnota vlastnosti

Hodnota ICollection , která poskytuje hodnoty v objektu StringDictionary.

Příklady

Následující příklad kódu vyčísluje prvky .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

Poznámky

Pořadí hodnot v ICollection zadaném pořadí není zadáno, ale je to stejné pořadí jako přidružené klíče vracené ICollection metodou Keys .

Vrácená ICollection hodnota není statická kopie. ICollection Místo toho odkazuje zpět na hodnoty v původním StringDictionarysouboru . Proto se změny nadále StringDictionary projeví v ICollectionsouboru .

Načtení hodnoty této vlastnosti je operace O(1).

Platí pro