Updated: July 2009
Represents a group of related sections within a configuration file.
Assembly: System.Configuration (in System.Configuration.dll)
Settings in configuration files (such as the Web.config file) are organized into sections. Because some sections are related, it is often convenient to group them in a section group. The class represents the sectionGroup XML element that is used to group sections when they are defined in the configSections element of a configuration file. Section groups can be nested (a section group can contain other section groups as well as sections). The following example shows a configSections element that defines three nested section groups:
<configSections> <sectionGroup name="system.web.extensions"...> <sectionGroup name="scripting" ...> <section name="scriptResourceHandler".../> <sectionGroup name="webServices"...> <section name="jsonSerialization" .../> <section name="profileService" ... /> <section name="authenticationService" .../> <section name="roleService" .../> </sectionGroup> </sectionGroup> </sectionGroup> </configSections>
The configuration system loads settings from configuration files into objects. You can use the Sections and SectionGroups properties to access the sections and section groups that are contained in a object.
For more information about how to access information from configuration files, see the ConfigurationManager class.
The following example shows how to use the class to retrieve configuration settings. The example is a console application that reads configuration settings and writes information about each configuration section group and the sections in it to the console.
The Main method loads the configuration settings into a Configuration object, retrieves the SectionGroups collection from the Configuration object, and then calls the ShowSectionGroupCollectionInfo method to display the section property values.
The ShowSectionGroupCollectionInfo method iterates through the section groups and calls the ShowSectionGroupInfo method for each one.
The ShowSectionGroupInfo method displays the name of the section group, some property values, and the names of the sections that it contains. If the section group contains section groups, this method calls ShowSectionGroupCollectionInfo recursively to display those section groups.
The indentLevel field is used to add spaces to the left side of displayed lines to show logical groupings. All lines are limited to 79 characters of text to avoid line wrapping, which would make it harder to distinguish the logical groupings.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.