Прочетете на английски Редактиране

Споделяне чрез


ConfigurationSectionGroupCollection.Item[] Property

Definition

Gets or sets a ConfigurationSectionGroup object contained in this ConfigurationSectionGroupCollection object.

Overloads

Item[Int32]

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

Item[String]

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

Examples

The following example shows how to use the Item[] property to iterate through a ConfigurationSectionGroupCollection.

C#
static void ShowSectionGroupCollectionInfo(ConfigurationSectionGroupCollection mySectionGroupCollection)
{
    foreach (String mySectionGroupName in mySectionGroupCollection.Keys)
    {
        ConfigurationSectionGroup mySectionGroup = 
            (ConfigurationSectionGroup)mySectionGroupCollection[mySectionGroupName];
        ShowSectionGroupInfo(mySectionGroup);
    }
}

Item[Int32]

Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs

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

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

Parameters

index
Int32

The index of the ConfigurationSectionGroup object to be returned.

Property Value

The ConfigurationSectionGroup object at the specified index.

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

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.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:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs

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

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

Parameters

name
String

The name of the ConfigurationSectionGroup object to be returned.

Property Value

The ConfigurationSectionGroup object with the specified name.

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

Examples

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

C#
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());
    }
}

See also

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.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