ConfigurationSectionCollection.Get メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
このConfigurationSection オブジェクトからConfigurationSectionCollection オブジェクトを取得します。
オーバーロード
| 名前 | 説明 |
|---|---|
| Get(Int32) |
このConfigurationSection オブジェクトに含まれる指定したConfigurationSectionCollection オブジェクトを取得します。 |
| Get(String) |
このConfigurationSection オブジェクトに含まれる指定したConfigurationSectionCollection オブジェクトを取得します。 |
Get(Int32)
このConfigurationSection オブジェクトに含まれる指定したConfigurationSectionCollection オブジェクトを取得します。
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
パラメーター
- index
- Int32
返される ConfigurationSection オブジェクトのインデックス。
返品
指定したインデックス位置にある ConfigurationSection オブジェクト。
適用対象
Get(String)
このConfigurationSection オブジェクトに含まれる指定したConfigurationSectionCollection オブジェクトを取得します。
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
パラメーター
- name
- String
返される ConfigurationSection オブジェクトの名前。
返品
指定した名前の ConfigurationSection オブジェクト。
例外
name が null または空の文字列 ("") です。
例
次のコード例は、 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