Comparteix a través de


ConfigurationSectionGroupCollection.Item[] Propiedad

Definición

Obtiene o establece un objeto ConfigurationSectionGroup contenido en este objeto ConfigurationSectionGroupCollection.

Sobrecargas

Item[Int32]

Obtiene de la colección el objeto ConfigurationSectionGroup del que se especifica el índice.

Item[String]

Obtiene de la colección el objeto ConfigurationSectionGroup del que se especifica el nombre.

Ejemplos

En el ejemplo siguiente se muestra cómo usar la Item[] propiedad para recorrer en iteración .ConfigurationSectionGroupCollection

static void ShowSectionGroupCollectionInfo(ConfigurationSectionGroupCollection mySectionGroupCollection)
{
    foreach (String mySectionGroupName in mySectionGroupCollection.Keys)
    {
        ConfigurationSectionGroup mySectionGroup = 
            (ConfigurationSectionGroup)mySectionGroupCollection[mySectionGroupName];
        ShowSectionGroupInfo(mySectionGroup);
    }
}
Shared Sub ShowSectionGroupCollectionInfo(mySectionGroupCollection As System.Configuration.ConfigurationSectionGroupCollection)
    Dim mySectionGroupName As String
    For Each mySectionGroupName In  mySectionGroupCollection.Keys
        Dim mySectionGroup As System.Configuration.ConfigurationSectionGroup = CType(mySectionGroupCollection(mySectionGroupName), System.Configuration.ConfigurationSectionGroup)
        ShowSectionGroupInfo(mySectionGroup)
    Next mySectionGroupName
End Sub

Item[Int32]

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

Obtiene de la colección el objeto ConfigurationSectionGroup del que se especifica el índice.

public:
 property System::Configuration::ConfigurationSectionGroup ^ default[int] { System::Configuration::ConfigurationSectionGroup ^ get(int index); };
public System.Configuration.ConfigurationSectionGroup this[int index] { get; }
member this.Item(int) : System.Configuration.ConfigurationSectionGroup
Default Public ReadOnly Property Item(index As Integer) As ConfigurationSectionGroup

Parámetros

index
Int32

Índice del objeto ConfigurationSectionGroup que se va a devolver.

Valor de propiedad

Objeto ConfigurationSectionGroup en el índice especificado.

En C#, esta propiedad es el indizador para la clase ConfigurationSectionCollection.

Se aplica a

Item[String]

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

Obtiene de la colección el objeto ConfigurationSectionGroup del que se especifica el nombre.

public:
 property System::Configuration::ConfigurationSectionGroup ^ default[System::String ^] { System::Configuration::ConfigurationSectionGroup ^ get(System::String ^ name); };
public System.Configuration.ConfigurationSectionGroup this[string name] { get; }
member this.Item(string) : System.Configuration.ConfigurationSectionGroup
Default Public ReadOnly Property Item(name As String) As ConfigurationSectionGroup

Parámetros

name
String

Nombre del objeto ConfigurationSectionGroup que se va a devolver.

Valor de propiedad

Objeto ConfigurationSectionGroup con el nombre especificado.

En C#, esta propiedad es el indizador para la clase ConfigurationSectionCollection.

Ejemplos

En el ejemplo de código siguiente se muestra cómo utilizar la propiedad Item[].

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());
    }
}
Shared Sub GetItems()
   
   Try
         Dim config _
     As System.Configuration.Configuration = _
     ConfigurationManager.OpenExeConfiguration( _
     ConfigurationUserLevel.None)

         Dim groups _
         As ConfigurationSectionGroupCollection = _
         config.SectionGroups

         Dim group1 As ConfigurationSectionGroup = _
         groups.Get("system.net")
      
         Dim group2 As ConfigurationSectionGroup = _
         groups.Get("system.web")
      
      
      Console.WriteLine("Group1: {0}", group1.Name)
      
      Console.WriteLine("Group2: {0}", group2.Name)
   
   Catch err As ConfigurationErrorsException
      Console.WriteLine(err.ToString())
   End Try
End Sub

Consulte también

Se aplica a