ConfigurationSectionGroupCollection.Remove(String) ConfigurationSectionGroupCollection.Remove(String) ConfigurationSectionGroupCollection.Remove(String) ConfigurationSectionGroupCollection.Remove(String) Method

Definition

Entfernt das ConfigurationSectionGroup-Objekt, dessen Name von diesem ConfigurationSectionGroupCollection-Objekt angegeben wird.Removes the ConfigurationSectionGroup object whose name is specified from this ConfigurationSectionGroupCollection object.

public:
 void Remove(System::String ^ name);
public void Remove (string name);
member this.Remove : string -> unit
Public Sub Remove (name As String)

Parameter

name
String String String String

Der Name der zu entfernenden Abschnittsgruppe.The name of the section group to be removed.

Beispiele

Im folgenden Codebeispiel wird die Verwendung der Remove-Methode veranschaulicht.The following code example shows how to use the Remove method.

static void Remove()
{

    try
    {

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

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

        if (customGroup != null)
        {
            config.SectionGroups.Remove("CustomGroup");
            config.Save(ConfigurationSaveMode.Full);
        }
        else
            Console.WriteLine(
                "CustomGroup does not exists.");

    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }
}
Shared Sub Remove()
   
   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 Not (customGroup Is Nothing) Then
         config.SectionGroups.Remove("CustomGroup")
         config.Save(ConfigurationSaveMode.Full)
      Else
             Console.WriteLine( _
             "CustomGroup does not exists.")
      End If
   
   Catch err As ConfigurationErrorsException
      Console.WriteLine(err.ToString())
   End Try
End Sub

Gilt für:

Siehe auch