This documentation is archived and is not being maintained.

Configuration.GetSection Method

Note: This method is new in the .NET Framework version 2.0.

Returns the specified ConfigurationSection object.

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

public ConfigurationSection GetSection (
	string sectionName
public ConfigurationSection GetSection (
	String sectionName
public function GetSection (
	sectionName : String
) : ConfigurationSection



The path to the section to be returned.

Return Value

The specified ConfigurationSection object.

Configuration settings are contained within sections that group similar settings together for convenience. The GetSection method retrieves a configuration section by its name.

The following code example demonstrates how to use the GetSection method to access custom section information.

// Get a custom section.
static void GetSection()

        CustomSection customSection;

        // Get the current configuration file.
        System.Configuration.Configuration config =
                ConfigurationUserLevel.None) as Configuration;

        customSection = 
            config.GetSection("CustomSection") as CustomSection;
        Console.WriteLine("Section name: {0", 

    catch (ConfigurationErrorsException err)

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0