ConfigurationSectionCollection.Get Methode
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 haalt u een ConfigurationSection object op van dit ConfigurationSectionCollection object.
Overloads
| Name | Description |
|---|---|
| Get(Int32) |
Hiermee wordt het opgegeven ConfigurationSection object opgehaald dat in dit ConfigurationSectionCollection object is opgenomen. |
| Get(String) |
Hiermee wordt het opgegeven ConfigurationSection object opgehaald dat in dit ConfigurationSectionCollection object is opgenomen. |
Get(Int32)
Hiermee wordt het opgegeven ConfigurationSection object opgehaald dat in dit ConfigurationSectionCollection object is opgenomen.
public:
System::Configuration::ConfigurationSection ^ Get(int index);
public System.Configuration.ConfigurationSection Get(int index);
member this.Get : int -> System.Configuration.ConfigurationSection
Public Function Get (index As Integer) As ConfigurationSection
Parameters
- index
- Int32
De index van het ConfigurationSection object dat moet worden geretourneerd.
Retouren
Het ConfigurationSection object op de opgegeven index.
Van toepassing op
Get(String)
Hiermee wordt het opgegeven ConfigurationSection object opgehaald dat in dit ConfigurationSectionCollection object is opgenomen.
public:
System::Configuration::ConfigurationSection ^ Get(System::String ^ name);
public System.Configuration.ConfigurationSection Get(string name);
member this.Get : string -> System.Configuration.ConfigurationSection
Public Function Get (name As String) As ConfigurationSection
Parameters
- name
- String
De naam van het ConfigurationSection object dat moet worden geretourneerd.
Retouren
Het ConfigurationSection object met de opgegeven naam.
Uitzonderingen
name is null of een lege tekenreeks ("").
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u deze kunt gebruiken Get.
static void GetSection()
{
try
{
CustomSection customSection =
ConfigurationManager.GetSection(
"CustomSection") as CustomSection;
if (customSection == null)
Console.WriteLine(
"Failed to load CustomSection.");
else
{
// Display section information
Console.WriteLine("Defaults:");
Console.WriteLine("File Name: {0}",
customSection.FileName);
Console.WriteLine("Max Users: {0}",
customSection.MaxUsers);
Console.WriteLine("Max Idle Time: {0}",
customSection.MaxIdleTime);
}
}
catch (ConfigurationErrorsException err)
{
Console.WriteLine(err.ToString());
}
}
Shared Sub GetSection()
Try
Dim customSection _
As CustomSection = _
ConfigurationManager.GetSection( _
"CustomSection")
If customSection Is Nothing Then
Console.WriteLine("Failed to load CustomSection.")
Else
' Display section information
Console.WriteLine("Defaults:")
Console.WriteLine("File Name: {0}", _
customSection.FileName)
Console.WriteLine("Max Users: {0}", _
customSection.MaxUsers)
Console.WriteLine("Max Idle Time: {0}", _
customSection.MaxIdleTime)
End If
Catch err As ConfigurationErrorsException
Console.WriteLine(err.ToString())
End Try
End Sub