ConfigurationElementCollection.BaseClear 方法

定义

从集合中移除所有配置元素对象。Removes all configuration element objects from the collection.

protected:
 void BaseClear();
protected public:
 void BaseClear();
protected void BaseClear ();
protected internal void BaseClear ();
member this.BaseClear : unit -> unit
Protected Sub BaseClear ()
Protected Friend Sub BaseClear ()

例外

配置是只读的。The configuration is read-only.

-or-

集合项已在更高级别的配置中锁定。A collection item has been locked in a higher-level configuration.

示例

下面的代码示例演示如何调用 BaseClear 方法。The following code example shows how to call the BaseClear method.

public void Remove(UrlConfigElement url)
{
    if (BaseIndexOf(url) >= 0)
    {
        BaseRemove(url.Name);
        // Your custom code goes here.
        Console.WriteLine("UrlsCollection: {0}", "Removed collection element!");
    }
}
Public Sub Remove(ByVal url As UrlConfigElement)
    If BaseIndexOf(url) >= 0 Then
        BaseRemove(url.Name)
        ' Your custom code goes here.
        Console.WriteLine("UrlsCollection: {0}", "Removed collection element!")
    End If
End Sub

注解

调用 BaseClear 方法时,它将从集合中移除所有 ConfigurationElement 对象。When the BaseClear method is called, it removes all ConfigurationElement objects from the collection. 它还将 clear 指令插入到配置文件中。It also inserts a clear directive into the configuration file.

适用于