Editar

Compartilhar via


ConfigurationSectionGroupCollection.Get Method

Definition

Gets a ConfigurationSectionGroup object from the collection.

Overloads

Get(Int32)

Gets the specified ConfigurationSectionGroup object contained in the collection.

Get(String)

Gets the specified ConfigurationSectionGroup object from the collection.

Remarks

This method is a wrapper around the BaseGet method.

Get(Int32)

Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs

Gets the specified ConfigurationSectionGroup object contained in the collection.

public:
 System::Configuration::ConfigurationSectionGroup ^ Get(int index);
public System.Configuration.ConfigurationSectionGroup Get (int index);
member this.Get : int -> System.Configuration.ConfigurationSectionGroup
Public Function Get (index As Integer) As ConfigurationSectionGroup

Parameters

index
Int32

The index of the ConfigurationSectionGroup object to be returned.

Returns

The ConfigurationSectionGroup object at the specified index.

Remarks

This method is a wrapper around the BaseGet method.

Applies to

Get(String)

Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs

Gets the specified ConfigurationSectionGroup object from the collection.

public:
 System::Configuration::ConfigurationSectionGroup ^ Get(System::String ^ name);
public System.Configuration.ConfigurationSectionGroup Get (string name);
member this.Get : string -> System.Configuration.ConfigurationSectionGroup
Public Function Get (name As String) As ConfigurationSectionGroup

Parameters

name
String

The name of the ConfigurationSectionGroup object to be returned.

Returns

The ConfigurationSectionGroup object with the specified name.

Exceptions

name is null or an empty string ("").

Examples

The following code example shows how to use the Get method.

static void GetGroup()
{

    try
    {
        System.Configuration.Configuration config =
        ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);

        ConfigurationSectionGroup customGroup =
            config.SectionGroups.Get("CustomGroup");

        if (customGroup == null)
            Console.WriteLine(
                "Failed to load CustomSection.");
        else
        {
            // Display section information
            Console.WriteLine("Section group name:       {0}",
                customGroup.SectionGroupName);
            Console.WriteLine("Name:       {0}",
                customGroup.Name);
            Console.WriteLine("Type:   {0}",
                customGroup.Type);
        }
    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }
}
Shared Sub GetGroup()
   
   Try
         Dim config _
         As System.Configuration.Configuration = _
         ConfigurationManager.OpenExeConfiguration( _
         ConfigurationUserLevel.None)

         Dim groups _
         As ConfigurationSectionGroupCollection = _
         config.SectionGroups

         Dim customGroup _
         As ConfigurationSectionGroup = _
         groups.Get("CustomGroup")
      
      
      If customGroup Is Nothing Then
             Console.WriteLine( _
             "Failed to load CustomGroup.")
      Else
         ' Display section information
             Console.WriteLine("Name:       {0}", _
             customGroup.Name)
             Console.WriteLine("Type:   {0}", _
             customGroup.Type)
      End If
   
   
   Catch err As ConfigurationErrorsException
      Console.WriteLine(err.ToString())
   End Try
End Sub

Remarks

This method is a wrapper around the BaseGet method.

See also

Applies to