KeyValuePair<TKey,TValue>.Value 屬性

定義

取得索引鍵/值組中的值。Gets the value in the key/value pair.

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

屬性值

TValue

TValue,其為 KeyValuePair<TKey,TValue> 的值。A TValue that is the value of the KeyValuePair<TKey,TValue>.

範例

下列程式碼範例示範如何使用 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.

適用於