ConfigurationSectionCollection.Item[] Property

Definition

Gets the specified ConfigurationSection object.

Overloads

Item[Int32]

Gets the specified ConfigurationSection object.

Item[String]

Gets the specified ConfigurationSection object.

Item[Int32]

Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs

Gets the specified ConfigurationSection object.

C#
public System.Configuration.ConfigurationSection this[int index] { get; }

Parameters

index
Int32

The index of the ConfigurationSection object to be returned.

Property Value

The ConfigurationSection object at the specified index.

Examples

The following code example shows how to use Item[].

C#
static void GetItems()
{

    try
    {
        System.Configuration.Configuration config =
        ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);

        ConfigurationSectionCollection sections =
            config.Sections;

        ConfigurationSection section1 =
            sections["runtime"];

        ConfigurationSection section2 =
            sections[0];

        Console.WriteLine(
             "Section1: {0}", section1.SectionInformation.Name);

        Console.WriteLine(
            "Section2: {0}", section2.SectionInformation.Name);
    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }
}

Remarks

This property gets the specified entry of the ConfigurationSectionCollection object.

In C#, this property is the indexer for the ConfigurationSectionCollection class.

See also

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Item[String]

Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs

Gets the specified ConfigurationSection object.

C#
public System.Configuration.ConfigurationSection this[string name] { get; }

Parameters

name
String

The name of the ConfigurationSection object to be returned.

Property Value

The ConfigurationSection object with the specified name.

Examples

The following code example shows how to use Item[].

C#
static void GetItems()
{

    try
    {
        System.Configuration.Configuration config =
        ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);

        ConfigurationSectionCollection sections =
            config.Sections;

        ConfigurationSection section1 =
            sections["runtime"];

        ConfigurationSection section2 =
            sections[0];

        Console.WriteLine(
             "Section1: {0}", section1.SectionInformation.Name);

        Console.WriteLine(
            "Section2: {0}", section2.SectionInformation.Name);
    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }
}

Remarks

This property gets the specified entry of the ConfigurationSectionCollection object.

In C#, this property is the indexer for the ConfigurationSectionCollection class.

See also

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10