KeyValuePair<TKey,TValue>.Key プロパティ

定義

キーと値のペアのキーを取得します。

public:
 property TKey Key { TKey get(); };
public TKey Key { get; }
member this.Key : 'Key
Public ReadOnly Property Key As TKey

プロパティ値

TKey

TKeyのキーであるKeyValuePair<TKey,TValue>

次のコード例は、 KeyValuePair<TKey,TValue> 構造体を使用してディクショナリ内のキーと値を列挙する方法を示しています。

このコードは、 Dictionary<TKey,TValue> クラスに提供されるより大きな例の一部です。

// When you use foreach to enumerate dictionary elements,
// the elements are retrieved as KeyValuePair objects.
Console.WriteLine();
foreach( KeyValuePair<string, string> kvp in openWith )
{
    Console.WriteLine("Key = {0}, Value = {1}",
        kvp.Key, kvp.Value);
}
' When you use foreach to enumerate dictionary elements,
' the elements are retrieved as KeyValuePair objects.
Console.WriteLine()
For Each kvp As KeyValuePair(Of String, String) In openWith
    Console.WriteLine("Key = {0}, Value = {1}", _
        kvp.Key, kvp.Value)
Next kvp

注釈

このプロパティは読み取り専用です。

適用対象