Freigeben über


ConfigurationSectionCollection.Get Methode

Definition

Ruft ein ConfigurationSection-Objekt aus diesem ConfigurationSectionCollection-Objekt ab.

Überlädt

Get(Int32)

Ruft das angegebene ConfigurationSection-Objekt ab, das in diesem ConfigurationSectionCollection-Objekt enthalten ist.

Get(String)

Ruft das angegebene ConfigurationSection-Objekt ab, das in diesem ConfigurationSectionCollection-Objekt enthalten ist.

Get(Int32)

Quelle:
ConfigurationSectionCollection.cs
Quelle:
ConfigurationSectionCollection.cs
Quelle:
ConfigurationSectionCollection.cs

Ruft das angegebene ConfigurationSection-Objekt ab, das in diesem ConfigurationSectionCollection-Objekt enthalten ist.

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

Parameter

index
Int32

Der Index des zurückzugebenden ConfigurationSection-Objekts.

Gibt zurück

Das ConfigurationSection-Objekt am angegebenen Index.

Gilt für:

Get(String)

Quelle:
ConfigurationSectionCollection.cs
Quelle:
ConfigurationSectionCollection.cs
Quelle:
ConfigurationSectionCollection.cs

Ruft das angegebene ConfigurationSection-Objekt ab, das in diesem ConfigurationSectionCollection-Objekt enthalten ist.

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

Parameter

name
String

Der Name des zurückzugebenden ConfigurationSection-Objekts.

Gibt zurück

Das ConfigurationSection-Objekt mit dem angegebenen Namen.

Ausnahmen

name ist NULL oder eine leere Zeichenfolge ("").

Beispiele

Im folgenden Codebeispiel wird die Verwendung von Get veranschaulicht.

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

Weitere Informationen

Gilt für: