SectionInformation.GetParentSection Method ()

 
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 configuration section that contains the configuration section associated with this object.

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

public ConfigurationSection GetParentSection()

Return Value

Type: System.Configuration.ConfigurationSection

The configuration section that contains the ConfigurationSection that is associated with this SectionInformation object.

Exception Condition
InvalidOperationException

The method is invoked from a parent section.

If this ConfigurationSection object has no parent sections, the GetParentSection method returns the same value as the Name property.

The following example shows how to use the GetParentSection method.

static public void GetParentSection()
{
    SectionInformation sInfo = 
        GetSectionInformation();

    ConfigurationSection parentSection =
        sInfo.GetParentSection();

    Console.WriteLine("Parent section : {0}",
        parentSection.SectionInformation.Name);

}

.NET Framework
Available since 2.0
Return to top
Show: