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.

适用于