KeyValuePair<TKey,TValue>.Key KeyValuePair<TKey,TValue>.Key KeyValuePair<TKey,TValue>.Key KeyValuePair<TKey,TValue>.Key Property

定義

キー/値ペア内のキーを取得します。 Gets the key in the key/value pair.

public:
 property TKey Key { TKey get(); };
public TKey Key { get; }
member this.Key : 'Key
Public ReadOnly Property Key As TKey
プロパティ値
TKey TKey TKey TKey

KeyValuePair<TKey,TValue> 内のキーを表す TKey A TKey that is the key of the KeyValuePair<TKey,TValue>.

次のコード例は、キーと、dictionary 内の値を列挙する方法を示しています。 を使用して、KeyValuePair<TKey,TValue>構造体。The following code example shows how to enumerate the keys and values in a dictionary, using the KeyValuePair<TKey,TValue> structure.

このコードは示されている例の一部、Dictionary<TKey,TValue>クラス。This code is part of a larger example provided for the Dictionary<TKey,TValue> class.

// When you use foreach to enumerate dictionary elements,
// the elements are retrieved as KeyValuePair objects.
Console::WriteLine();
for each( 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();
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

注釈

このプロパティは、読み取り専用です。This property is read/only.

適用対象