共用方式為


DiscoveryClientDocumentCollection.Add(String, Object) 方法

定義

將有指定 URL 的物件加入至 DiscoveryClientDocumentCollection

public:
 void Add(System::String ^ url, System::Object ^ value);
public void Add (string url, object value);
member this.Add : string * obj -> unit
Public Sub Add (url As String, value As Object)

參數

url
String

要加入至 DiscoveryClientDocumentCollection 的文件之 URL。

value
Object

要加入至 DiscoveryClientDocumentCollection 的探索文件。

例外狀況

urlnull

具有 url 的索引鍵的項目已經存在於 DiscoveryClientDocumentCollection 中。

範例

下列程式碼範例會將兩個 DiscoveryClientDocumentCollection 探索檔新增至 。

DiscoveryClientDocumentCollection^ myDiscoveryClientDocumentCollection = gcnew DiscoveryClientDocumentCollection;

DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument;
String^ myStringUrl = "http://www.contoso.com/service.disco";
String^ myStringUrl1 = "http://www.contoso.com/service1.disco";
myDiscoveryClientDocumentCollection->Add( myStringUrl, myDiscoveryDocument );
myDiscoveryClientDocumentCollection->Add( myStringUrl1, myDiscoveryDocument );
DiscoveryClientDocumentCollection myDiscoveryClientDocumentCollection =
   new DiscoveryClientDocumentCollection();
DiscoveryDocument myDiscoveryDocument = new DiscoveryDocument();
string myStringUrl = "http://www.contoso.com/service.disco";
string myStringUrl1 = "http://www.contoso.com/service1.disco";

myDiscoveryClientDocumentCollection.Add(myStringUrl, myDiscoveryDocument);
myDiscoveryClientDocumentCollection.Add(myStringUrl1, myDiscoveryDocument);
Dim myDiscoveryClientDocumentCollection As New DiscoveryClientDocumentCollection()
Dim myDiscoveryDocument As New DiscoveryDocument()
Dim myStringUrl As String = "http://www.contoso.com/service.disco"
Dim myStringUrl1 As String = "http://www.contoso.com/service1.disco"

myDiscoveryClientDocumentCollection.Add(myStringUrl, myDiscoveryDocument)
myDiscoveryClientDocumentCollection.Add(myStringUrl1, myDiscoveryDocument)

適用於

另請參閱