Share via


ConfigurationSectionCollection.Get メソッド

定義

この ConfigurationSection オブジェクトから ConfigurationSectionCollection オブジェクトを取得します。

オーバーロード

Get(Int32)

この ConfigurationSection オブジェクトに格納されている、指定した ConfigurationSectionCollection オブジェクトを取得します。

Get(String)

この ConfigurationSection オブジェクトに格納されている、指定した ConfigurationSectionCollection オブジェクトを取得します。

Get(Int32)

ソース:
ConfigurationSectionCollection.cs
ソース:
ConfigurationSectionCollection.cs
ソース:
ConfigurationSectionCollection.cs

この 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)

ソース:
ConfigurationSectionCollection.cs
ソース:
ConfigurationSectionCollection.cs
ソース:
ConfigurationSectionCollection.cs

この 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

こちらもご覧ください

適用対象