ConfigurationSectionCollection.Item[] Egenskap

Definition

Hämtar det angivna ConfigurationSection objektet.

Överlagringar

Name Description
Item[Int32]

Hämtar det angivna ConfigurationSection objektet.

Item[String]

Hämtar det angivna ConfigurationSection objektet.

Item[Int32]

Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs

Hämtar det angivna ConfigurationSection objektet.

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

Parametrar

index
Int32

Indexet för det objekt som ConfigurationSection ska returneras.

Egenskapsvärde

Objektet ConfigurationSection i det angivna indexet.

Exempel

Följande kodexempel visar hur du använder 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

Kommentarer

Den här egenskapen hämtar den angivna posten för ConfigurationSectionCollection objektet.

I C# är den här egenskapen indexeraren för ConfigurationSectionCollection klassen.

Se även

Gäller för

Item[String]

Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs

Hämtar det angivna ConfigurationSection objektet.

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

Parametrar

name
String

Namnet på det objekt som ConfigurationSection ska returneras.

Egenskapsvärde

Objektet ConfigurationSection med det angivna namnet.

Exempel

Följande kodexempel visar hur du använder 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

Kommentarer

Den här egenskapen hämtar den angivna posten för ConfigurationSectionCollection objektet.

I C# är den här egenskapen indexeraren för ConfigurationSectionCollection klassen.

Se även

Gäller för