GetSection Method (IConfigurationSettings)
- Last UpdatedApr 08, 2026
- 1 minute read
Gets the configuration section associated with the specified name(s).
IConfigurationSettingsSection GetSection(
string name,
params string[] additionalNames
)
IConfigurationSettingsSection^ GetSection(
String^ name,
... array<String^>^ additionalNames
)
Parameters
- name
- The section name.
- additionalNames
- The optional set of additional section names.
Return Value
The configuration settings section associated with the specified name(s).
| Exception | Description |
|---|---|
| System.InvalidOperationException | One or more of the specified section names exist; but the value does not represent a configuration section. |
If a section name does not exist, an empty configuration settings collection will be returned; the only time GetSection will throw an exception is if a name exists, but does not represent a configuration section (i.e., the name is associated with a primitive value or list).
Sample JSON configuration
Get the root 'RealTime' configuration settings section.
Get the 'ManagementOfChange' sub-section contained within the root 'RealTime' configuration section.
{ "RealTime": { "ManagementOfChange": { "Enabled": true } } } settings.GetSection("RealTime"); settings.GetSection("RealTime", "ManagementOfChange");{
"RealTime": {
"ManagementOfChange": {
"Enabled": true
}
}
}
settings.GetSection("RealTime");
settings.GetSection("RealTime", "ManagementOfChange");