ConfigurationSectionCollection.Get Method

Definition

Gets a ConfigurationSection object from this ConfigurationSectionCollection object.

Overloads

Get(Int32)

Gets the specified ConfigurationSection object contained in this ConfigurationSectionCollection object.

Get(String)

Gets the specified ConfigurationSection object contained in this ConfigurationSectionCollection object.

Get(Int32)

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

Gets the specified ConfigurationSection object contained in this ConfigurationSectionCollection object.

C#
public System.Configuration.ConfigurationSection Get(int index);

Parameters

index
Int32

The index of the ConfigurationSection object to be returned.

Returns

The ConfigurationSection object at the specified index.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Get(String)

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

Gets the specified ConfigurationSection object contained in this ConfigurationSectionCollection object.

C#
public System.Configuration.ConfigurationSection Get(string name);

Parameters

name
String

The name of the ConfigurationSection object to be returned.

Returns

The ConfigurationSection object with the specified name.

Exceptions

name is null or an empty string ("").

Examples

The following code example shows how to use Get.

C#
static void GetSection()
{

    try
    {
        CustomSection customSection =
            ConfigurationManager.GetSection(
            "CustomSection") as CustomSection;

        if (customSection == null)
            Console.WriteLine(
                "Failed to load CustomSection.");
        else
        {
            // Display section information
            Console.WriteLine("Defaults:");
            Console.WriteLine("File Name:       {0}",
                customSection.FileName);
            Console.WriteLine("Max Users:       {0}",
                customSection.MaxUsers);
            Console.WriteLine("Max Idle Time:   {0}",
                customSection.MaxIdleTime);
        }
    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }
}

See also

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9