ConfigurationSectionCollection.Item[] Propriedade

Definição

Obtém o objeto ConfigurationSection especificado.

Sobrecargas

Item[Int32]

Obtém o objeto ConfigurationSection especificado.

Item[String]

Obtém o objeto ConfigurationSection especificado.

Item[Int32]

Origem:
ConfigurationSectionCollection.cs
Origem:
ConfigurationSectionCollection.cs
Origem:
ConfigurationSectionCollection.cs

Obtém o objeto ConfigurationSection especificado.

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

Parâmetros

index
Int32

O índice do objeto ConfigurationSection a ser retornado.

Valor da propriedade

O objeto ConfigurationSection no índice especificado.

Exemplos

O exemplo de código a seguir mostra como usar Item[].

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());
    }
}
Shared Sub GetItems()

    Try
        Dim config _
        As System.Configuration.Configuration = _
        ConfigurationManager.OpenExeConfiguration( _
        ConfigurationUserLevel.None)

        Dim sections _
        As ConfigurationSectionCollection = _
        config.Sections


        Dim section1 As ConfigurationSection = _
        sections.Item("runtime")

        Dim section2 As ConfigurationSection = _
        sections.Item(0)

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

        Console.WriteLine("Section2: {0}", _
        section2.SectionInformation.Name)

    Catch err As ConfigurationErrorsException
        Console.WriteLine(err.ToString())
    End Try
End Sub

Comentários

Essa propriedade obtém a entrada especificada do ConfigurationSectionCollection objeto .

Em C#, essa propriedade é o indexador da classe ConfigurationSectionCollection.

Confira também

Aplica-se a

Item[String]

Origem:
ConfigurationSectionCollection.cs
Origem:
ConfigurationSectionCollection.cs
Origem:
ConfigurationSectionCollection.cs

Obtém o objeto ConfigurationSection especificado.

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

Parâmetros

name
String

O nome do objeto ConfigurationSection a ser retornado.

Valor da propriedade

O objeto ConfigurationSection com o nome especificado.

Exemplos

O exemplo de código a seguir mostra como usar Item[].

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());
    }
}
Shared Sub GetItems()

    Try
        Dim config _
        As System.Configuration.Configuration = _
        ConfigurationManager.OpenExeConfiguration( _
        ConfigurationUserLevel.None)

        Dim sections _
        As ConfigurationSectionCollection = _
        config.Sections


        Dim section1 As ConfigurationSection = _
        sections.Item("runtime")

        Dim section2 As ConfigurationSection = _
        sections.Item(0)

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

        Console.WriteLine("Section2: {0}", _
        section2.SectionInformation.Name)

    Catch err As ConfigurationErrorsException
        Console.WriteLine(err.ToString())
    End Try
End Sub

Comentários

Essa propriedade obtém a entrada especificada do ConfigurationSectionCollection objeto .

Em C#, essa propriedade é o indexador da classe ConfigurationSectionCollection.

Confira também

Aplica-se a