ConfigurationSection Constructor ()


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

Initializes a new instance of the ConfigurationSection class.

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

protected ConfigurationSection()

To use the ConfigurationSection constructor, you need to define a custom section type first. For an example see the ConfigurationSection class overview.

The following example shows how to use the ConfigurationSection constructor. This example assumes that you have created a custom section class named CustomSection. For an example of such a class, see the ConfigurationSection class overview.

// Create a custom section.
static void CreateSection()

        CustomSection customSection;

        // Get the current configuration file.
        System.Configuration.Configuration config =

        // Create the section entry  
        // in the <configSections> and the 
        // related target section in <configuration>.
        if (config.Sections["CustomSection"] == null)
            customSection = new CustomSection();
            config.Sections.Add("CustomSection", customSection);
            customSection.SectionInformation.ForceSave = true;
    catch (ConfigurationErrorsException err)


.NET Framework
Available since 2.0
Return to top