ConfigurationSectionCollection.Keys Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the keys to all ConfigurationSection objects contained in this ConfigurationSectionCollection object.
public:
virtual property System::Collections::Specialized::NameObjectCollectionBase::KeysCollection ^ Keys { System::Collections::Specialized::NameObjectCollectionBase::KeysCollection ^ get(); };
public override System.Collections.Specialized.NameObjectCollectionBase.KeysCollection Keys { get; }
member this.Keys : System.Collections.Specialized.NameObjectCollectionBase.KeysCollection
Public Overrides ReadOnly Property Keys As NameObjectCollectionBase.KeysCollection
Property Value
A NameObjectCollectionBase.KeysCollection object that contains the keys of all sections in this collection.
Examples
The following example shows how to use the Keys property.
static void GetKeys()
{
try
{
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
ConfigurationSectionCollection sections =
config.Sections;
foreach (string key in sections.Keys)
{
Console.WriteLine(
"Key value: {0}", key);
}
}
catch (ConfigurationErrorsException err)
{
Console.WriteLine(err.ToString());
}
}
Shared Sub GetKeys()
Try
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
Dim sections _
As ConfigurationSectionCollection = _
config.Sections
Dim key As String
For Each key In sections.Keys
Console.WriteLine("Key value: {0}", key)
Next key
Catch err As ConfigurationErrorsException
Console.WriteLine(err.ToString())
End Try
End Sub
Applies to
See also
Colaborați cu noi pe GitHub
Sursa pentru acest conținut poate fi găsită pe GitHub, unde puteți, de asemenea, să creați și să consultați probleme și solicitări de tragere. Pentru mai multe informații, consultați ghidul nostru pentru colaboratori.