ConfigurationSectionCollection.Get Metod

Definition

Hämtar ett ConfigurationSection objekt från det här ConfigurationSectionCollection objektet.

Överlagringar

Name Description
Get(Int32)

Hämtar det angivna ConfigurationSection objektet i det här ConfigurationSectionCollection objektet.

Get(String)

Hämtar det angivna ConfigurationSection objektet i det här ConfigurationSectionCollection objektet.

Get(Int32)

Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs

Hämtar det angivna ConfigurationSection objektet i det här ConfigurationSectionCollection objektet.

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

Parametrar

index
Int32

Indexet för det objekt som ConfigurationSection ska returneras.

Returer

Objektet ConfigurationSection i det angivna indexet.

Gäller för

Get(String)

Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs
Källa:
ConfigurationSectionCollection.cs

Hämtar det angivna ConfigurationSection objektet i det här ConfigurationSectionCollection objektet.

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

Parametrar

name
String

Namnet på det objekt som ConfigurationSection ska returneras.

Returer

Objektet ConfigurationSection med det angivna namnet.

Undantag

name är null eller en tom sträng ("").

Exempel

Följande kodexempel visar hur du använder 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

Se även

Gäller för