ClientTargetCollection.Add(ClientTarget) 方法
定义
将指定的 ClientTarget 对象添加到集合。Adds the specified ClientTarget object to the collection.
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。The ClientTarget to add to the collection.
示例
下面的代码示例将一个 ClientTarget 对象添加到 ClientTargetCollection 集合中。The following code example adds a ClientTarget object to the ClientTargetCollection collection.
有关如何获取集合的信息,请参阅类概述中的代码示例 ClientTargetCollection 。For information about how to get the collection, see to the code example in the ClientTargetCollection class overview.
// 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 对象并初始化其 Alias 和 UserAgent 属性。Before adding a client target to the collection, you must create a ClientTarget object and initialize its Alias and UserAgent properties.