ConfigurationSectionGroupCollection.Item Property (String)

 

Gets the ConfigurationSectionGroup object whose name is specified from the collection.

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

public ConfigurationSectionGroup this[
	string name
] { get; }

Parameters

name
Type: System.String

The name of the ConfigurationSectionGroup object to be returned.

Property Value

Type: System.Configuration.ConfigurationSectionGroup

The ConfigurationSectionGroup object with the specified name.

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

The following code example shows how to use the Item property.

static void GetItems()
{

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

        ConfigurationSectionGroupCollection groups =
            config.SectionGroups;

        ConfigurationSectionGroup group1 =
            groups.Get("system.net");

        ConfigurationSectionGroup group2 =
        groups.Get("system.web");


        Console.WriteLine(
             "Group1: {0}", group1.Name);

        Console.WriteLine(
            "Group2: {0}", group2.Name);

    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }
}

.NET Framework
Available since 2.0
Return to top
Show: