ConfigurationSectionCollection.Clear 方法

定义

清除此 ConfigurationSectionCollection 对象。

public:
 void Clear();
public void Clear ();
member this.Clear : unit -> unit
Public Sub Clear ()

示例

下面的代码示例说明如何使用 Clear 方法。

static void Clear()
{

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

        config.Sections.Clear();

        config.Save(ConfigurationSaveMode.Full);
    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }
}
Shared Sub Clear()

    Try
        Dim config _
        As System.Configuration.Configuration = _
        ConfigurationManager.OpenExeConfiguration( _
        ConfigurationUserLevel.None)

        config.Sections.Clear()

        config.Save( _
        ConfigurationSaveMode.Full)
    Catch err As ConfigurationErrorsException
        Console.WriteLine(err.ToString())
    End Try
End Sub

适用于

另请参阅