語言

ClientTargetCollection.Add(ClientTarget) 方法

定義

將指定的 ClientTarget 物件加入集合中。

public:
 void Add(System::Web::Configuration::ClientTarget ^ clientTarget);
public void Add(System.Web.Configuration.ClientTarget clientTarget);
member this.Add : System.Web.Configuration.ClientTarget -> unit
Public Sub Add (clientTarget As ClientTarget)

參數

clientTarget
ClientTarget

ClientTarget加入收藏。

範例

以下程式碼範例將 ClientTarget 物件加入 ClientTargetCollection 集合。

關於如何取得集合的資訊,請參考課程總覽中的 ClientTargetCollection 程式碼範例。


// Create a new ClientTarget object.
clientTarget = new ClientTarget(
  "my alias", "My User Agent"); 
  
// Add the clientTarget to 
// the collection.
clientTargets.Add(clientTarget);

// Update the configuration file.
if (!clientTargetSection.IsReadOnly())
  configuration.Save();
' Create a new ClientTarget object.
clientTarget = New ClientTarget( _
"my alias", "My User Agent")

' Add the clientTarget to 
' the collection.
clientTargets.Add(clientTarget)

' Update the configuration file.
If Not clientTargetSection.IsReadOnly() Then
    configuration.Save()
End If

備註

在將客戶端目標加入集合前,你必須建立ClientTarget一個物件並初始化其AliasUserAgent及屬性。

適用於

另請參閱