ClientTargetCollection.Clear 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
移除集合中的所有 ClientTarget 物件。
public:
void Clear();
public void Clear();
member this.Clear : unit -> unit
Public Sub Clear ()
範例
以下程式碼範例將移除集合中ClientTarget的所有ClientTargetCollection物件。
關於如何取得集合的資訊,請參閱課程總覽中的 ClientTargetCollection 程式碼範例。
// Clear the client target collection.
clientTargets.Clear();
// Update the configuration file.
if (!clientTargetSection.IsReadOnly())
configuration.Save();
' Clear the client target collection.
clientTargets.Clear()
' Update the configuration file.
If Not clientTargetSection.IsReadOnly() Then
configuration.Save()
End If
備註
呼叫該Clear方法後更新設定檔的結果取決於所選值。ConfigurationSaveMode 要更新設定檔,請使用以下兩種方法之一: Configuration.Save 或 Configuration.Save。
Note
呼叫 Configuration.Save 等 Save 同於當值被修改時 ConfigurationSaveMode 呼叫。
若使用此 Configuration.Save 方法,需遵守以下條件:
如果你傳遞 Full or Modified 參數值,那麼在當前階層層級的設定檔區段會插入
clear一個clientTarget元素。如果你傳遞參數值,Minimal
remove會在目前階層層級的設定檔區塊中加入clientTarget一系列元素。 此舉移除階層結構中父組態檔案中定義元素的所有參考add。 列 Minimal 舉值時,集合上的一個額外屬性會影響序列化到設定檔的內容。 屬性是 和 EmitClear 預設false為 。 以下其中一個條件適用:
此 Clear 方法實際上會 add 刪除設定檔中當前階層層級中定義 clientTarget 的元素。 它也會移除階層 add 結構中父組態檔案中定義元素的所有參考。
Note
add這些元素不會從clientTarget父組態檔案的區塊中刪除。