StringDictionary.Values プロパティ

定義

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

プロパティ値

ICollection内の値を提供するStringDictionary

次のコード例では、 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

注釈

ICollection内の値の順序は指定されていませんが、ICollection メソッドによって返されるKeys内の関連するキーと同じ順序です。

返された ICollection は静的コピーではありません。代わりに、 ICollection は元の StringDictionaryの値を参照します。 そのため、 StringDictionary への変更は引き続き ICollectionに反映されます。

このプロパティの値の取得は O(1) 操作です。

適用対象