KeyValueConfigurationElement.Key 属性

定义

获取 KeyValueConfigurationElement 对象的键。

public:
 property System::String ^ Key { System::String ^ get(); };
[System.Configuration.ConfigurationProperty("key", DefaultValue="", Options=System.Configuration.ConfigurationPropertyOptions.IsKey)]
public string Key { get; }
public string Key { get; }
[<System.Configuration.ConfigurationProperty("key", DefaultValue="", Options=System.Configuration.ConfigurationPropertyOptions.IsKey)>]
member this.Key : string
member this.Key : string
Public ReadOnly Property Key As String

属性值

KeyValueConfigurationElement 的键。

属性

示例

下面的代码示例演示如何使用 Key 属性。 此代码示例是为类概述提供的更大示例的 KeyValueConfigurationCollection 一部分。

// Display each KeyValueConfigurationElement.
foreach (KeyValueConfigurationElement keyValueElement in settings)
{
  Console.WriteLine("Key: {0}", keyValueElement.Key);
  Console.WriteLine("Value: {0}", keyValueElement.Value);
  Console.WriteLine();
}
' Display each KeyValueConfigurationElement.
Dim keyValueElement As KeyValueConfigurationElement
For Each keyValueElement In settings
  Console.WriteLine("Key: {0}", keyValueElement.Key)
  Console.WriteLine("Value: {0}", keyValueElement.Value)
  Console.WriteLine()
Next

适用于