KeyValuePair<TKey,TValue>.Key プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
キーと値のペアのキーを取得します。
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
注釈
このプロパティは読み取り専用です。