ConfigurationSectionCollection.Get Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a ConfigurationSection object from this ConfigurationSectionCollection object.
Overloads
Get(Int32) |
Gets the specified ConfigurationSection object contained in this ConfigurationSectionCollection object. |
Get(String) |
Gets the specified ConfigurationSection object contained in this ConfigurationSectionCollection object. |
Get(Int32)
Gets the specified ConfigurationSection object contained in this ConfigurationSectionCollection object.
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
The index of the ConfigurationSection object to be returned.
Returns
The ConfigurationSection object at the specified index.
Applies to
Get(String)
Gets the specified ConfigurationSection object contained in this ConfigurationSectionCollection object.
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
The name of the ConfigurationSection object to be returned.
Returns
The ConfigurationSection object with the specified name.
Exceptions
name
is null or an empty string ("").
Examples
The following code example shows how to use 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
See also
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기