ConfigurationSectionGroupCollection.Keys Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the keys to all ConfigurationSectionGroup objects contained in this ConfigurationSectionGroupCollection object.

Namespace:   System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)

public override NameObjectCollectionBase.KeysCollection Keys { get; }

Property Value

Type: System.Collections.Specialized.NameObjectCollectionBase.KeysCollection

A NameObjectCollectionBase.KeysCollection object that contains the names of all section groups in this collection.

The following code example shows how to use the Keys property.

// Get the collection keys i.e., the
// group names.
static void GetKeys()
{

    try
    {
        System.Configuration.Configuration config =
        ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);

        ConfigurationSectionGroupCollection groups =
            config.SectionGroups;

        foreach (string key in groups.Keys)
        {

            Console.WriteLine(
             "Key value: {0}", key);
        }


    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }
}

.NET Framework
Available since 2.0
Return to top
Show: