ConfigurationSectionCollection.Item[] Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee wordt het opgegeven ConfigurationSection object opgehaald.
Overloads
| Name | Description |
|---|---|
| Item[Int32] |
Hiermee wordt het opgegeven ConfigurationSection object opgehaald. |
| Item[String] |
Hiermee wordt het opgegeven ConfigurationSection object opgehaald. |
Item[Int32]
Hiermee wordt het opgegeven ConfigurationSection object opgehaald.
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
Parameters
- index
- Int32
De index van het ConfigurationSection object dat moet worden geretourneerd.
Waarde van eigenschap
Het ConfigurationSection object op de opgegeven index.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u deze kunt gebruiken 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
Opmerkingen
Met deze eigenschap wordt de opgegeven vermelding van het ConfigurationSectionCollection object opgehaald.
In C# is deze eigenschap de indexeerfunctie voor de ConfigurationSectionCollection klasse.
Zie ook
Van toepassing op
Item[String]
Hiermee wordt het opgegeven ConfigurationSection object opgehaald.
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
Parameters
- name
- String
De naam van het ConfigurationSection object dat moet worden geretourneerd.
Waarde van eigenschap
Het ConfigurationSection object met de opgegeven naam.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u deze kunt gebruiken 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
Opmerkingen
Met deze eigenschap wordt de opgegeven vermelding van het ConfigurationSectionCollection object opgehaald.
In C# is deze eigenschap de indexeerfunctie voor de ConfigurationSectionCollection klasse.