Compartir a través de


ConfigurationSectionCollection.Get Método

Definición

Obtiene un objeto ConfigurationSection de este objeto ConfigurationSectionCollection.

Sobrecargas

Get(Int32)

Obtiene el objeto ConfigurationSection especificado que incluye este objeto ConfigurationSectionCollection.

Get(String)

Obtiene el objeto ConfigurationSection especificado que incluye este objeto ConfigurationSectionCollection.

Get(Int32)

Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs

Obtiene el objeto ConfigurationSection especificado que incluye este objeto 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

Parámetros

index
Int32

Índice del objeto ConfigurationSection que se va a devolver.

Devoluciones

Objeto ConfigurationSection en el índice especificado.

Se aplica a

Get(String)

Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs
Source:
ConfigurationSectionCollection.cs

Obtiene el objeto ConfigurationSection especificado que incluye este objeto 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

Parámetros

name
String

Nombre del objeto ConfigurationSection que se va a devolver.

Devoluciones

Objeto ConfigurationSection con el nombre especificado.

Excepciones

El valor de name es null o una cadena vacía ("").

Ejemplos

En el ejemplo de código siguiente se muestra cómo utilizar 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

Consulte también

Se aplica a