DiscoveryReferenceCollection 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
探索參考的集合。 此類別無法獲得繼承。
public ref class DiscoveryReferenceCollection sealed : System::Collections::CollectionBase
public sealed class DiscoveryReferenceCollection : System.Collections.CollectionBase
type DiscoveryReferenceCollection = class
inherit CollectionBase
Public NotInheritable Class DiscoveryReferenceCollection
Inherits CollectionBase
- 繼承
範例
#using <System.Web.Services.dll>
using namespace System;
using namespace System::IO;
using namespace System::Web::Services::Discovery;
int main()
{
DiscoveryDocumentReference^ myDiscoveryDocReference1 = gcnew DiscoveryDocumentReference;
DiscoveryDocumentReference^ myDiscoveryDocReference2 = gcnew DiscoveryDocumentReference;
DiscoveryReference^ myDiscoveryReference;
Console::WriteLine( "Demonstrating DiscoveryReferenceCollection class." );
// Create new DiscoveryReferenceCollection.
DiscoveryReferenceCollection^ myDiscoveryReferenceCollection = gcnew DiscoveryReferenceCollection;
// Access the Count method.
Console::WriteLine( "The number of elements in the collection is: {0}", myDiscoveryReferenceCollection->Count );
// Add elements to the collection.
myDiscoveryReferenceCollection->Add( myDiscoveryDocReference1 );
myDiscoveryReferenceCollection->Add( myDiscoveryDocReference2 );
Console::WriteLine( "The number of elements in the collection after adding two elements to the collection: {0}", myDiscoveryReferenceCollection->Count );
// Call the Contains method.
if ( myDiscoveryReferenceCollection->Contains( myDiscoveryDocReference1 ) != true )
{
throw gcnew Exception( "Element not found in collection." );
}
// Access the indexed member.
myDiscoveryReference = dynamic_cast<DiscoveryReference^>(myDiscoveryReferenceCollection[ 0 ]);
if ( myDiscoveryReference == nullptr )
{
throw gcnew Exception( "Element not found in collection." );
}
// Remove one element from collection.
myDiscoveryReferenceCollection->Remove( myDiscoveryDocReference1 );
Console::WriteLine( "The number of elements in the collection after removing one element is: {0}", myDiscoveryReferenceCollection->Count );
}
using System;
using System.IO;
using System.Web.Services.Discovery;
class MyDiscoveryDocumentClass
{
static void Main()
{
DiscoveryDocumentReference myDiscoveryDocReference1 =
new DiscoveryDocumentReference();
DiscoveryDocumentReference myDiscoveryDocReference2 =
new DiscoveryDocumentReference();
DiscoveryReference myDiscoveryReference;
Console.WriteLine("Demonstrating DiscoveryReferenceCollection class.");
// Create new DiscoveryReferenceCollection.
DiscoveryReferenceCollection myDiscoveryReferenceCollection =
new DiscoveryReferenceCollection();
// Access the Count method.
Console.WriteLine("The number of elements in the collection is: "
+ myDiscoveryReferenceCollection.Count.ToString());
// Add elements to the collection.
myDiscoveryReferenceCollection.Add(myDiscoveryDocReference1);
myDiscoveryReferenceCollection.Add(myDiscoveryDocReference2);
Console.WriteLine("The number of elements in the collection "
+ "after adding two elements to the collection: "
+ myDiscoveryReferenceCollection.Count.ToString());
// Call the Contains method.
if (myDiscoveryReferenceCollection.Contains(myDiscoveryDocReference1)
!= true)
{
throw new Exception("Element not found in collection.");
}
// Access the indexed member.
myDiscoveryReference =
(DiscoveryReference)myDiscoveryReferenceCollection[0];
if (myDiscoveryReference == null)
{
throw new Exception("Element not found in collection.");
}
// Remove one element from collection.
myDiscoveryReferenceCollection.Remove(myDiscoveryDocReference1);
Console.WriteLine("The number of elements in the collection "
+ "after removing one element is: "
+ myDiscoveryReferenceCollection.Count.ToString());
}
}
Imports System.IO
Imports System.Web.Services.Discovery
Class MyDiscoveryDocumentMod
Shared Sub Main()
Try
Dim myDiscoveryDocReference1 As New DiscoveryDocumentReference()
Dim myDiscoveryDocReference2 As New DiscoveryDocumentReference()
Dim myDiscoveryReference As DiscoveryReference
Console.WriteLine("Demonstrating DiscoveryReferenceCollection class.")
' Create new DiscoveryReferenceCollection.
Dim myDiscoveryReferenceCollection As New DiscoveryReferenceCollection()
' Access the Count method.
Console.WriteLine("The number of elements in collection is: " & _
myDiscoveryReferenceCollection.Count.ToString())
' Add elements to the collection.
myDiscoveryReferenceCollection.Add(myDiscoveryDocReference1)
myDiscoveryReferenceCollection.Add(myDiscoveryDocReference2)
Console.WriteLine("The number of elements in the collection " _
& "after adding two elements to the collection: " _
& myDiscoveryReferenceCollection.Count.ToString())
' Call the Contains method.
If myDiscoveryReferenceCollection.Contains(myDiscoveryDocReference1) _
<> True Then
Throw New Exception("Element not found in collection.")
End If
' Access the Item property.
myDiscoveryReference = myDiscoveryReferenceCollection.Item(0)
If myDiscoveryReference Is Nothing Then
Throw New Exception("Element not found in collection.")
End If
' Remove one element from the collection.
myDiscoveryReferenceCollection.Remove(myDiscoveryDocReference1)
Console.WriteLine("The number of elements in collection " _
& "after removing one element is: " _
& myDiscoveryReferenceCollection.Count.ToString())
Catch e As Exception
Console.Writeline("Exception occurred : " + e.Message)
End Try
End Sub
End Class
建構函式
DiscoveryReferenceCollection() |
初始化 DiscoveryReferenceCollection 類別的新執行個體。 |
屬性
Capacity |
取得或設定 CollectionBase 可包含的項目數目。 (繼承來源 CollectionBase) |
Count |
取得 CollectionBase 執行個體中包含的元素數目。 這個屬性無法覆寫。 (繼承來源 CollectionBase) |
InnerList |
取得包含 ArrayList 執行個體中之元素清單的 CollectionBase。 (繼承來源 CollectionBase) |
Item[Int32] |
取得或設定在指定索引處的 DiscoveryReference。 |
List |
取得包含 IList 執行個體中之元素清單的 CollectionBase。 (繼承來源 CollectionBase) |
方法
明確介面實作
ICollection.CopyTo(Array, Int32) |
從目標陣列的指定索引開始,將整個 CollectionBase 複製到相容的一維 Array。 (繼承來源 CollectionBase) |
ICollection.IsSynchronized |
取得值,這個值表示對 CollectionBase 的存取是否同步 (安全執行緒)。 (繼承來源 CollectionBase) |
ICollection.SyncRoot |
取得可用以同步存取 CollectionBase 的物件。 (繼承來源 CollectionBase) |
IList.Add(Object) |
將物件加入至 CollectionBase 的末端。 (繼承來源 CollectionBase) |
IList.Contains(Object) |
判斷 CollectionBase 是否包含特定項目。 (繼承來源 CollectionBase) |
IList.IndexOf(Object) |
搜尋指定的 Object,並傳回在整個 CollectionBase 中第一個符合項目之以零為起始的索引。 (繼承來源 CollectionBase) |
IList.Insert(Int32, Object) |
將項目插入至 CollectionBase 中指定的索引位置。 (繼承來源 CollectionBase) |
IList.IsFixedSize |
取得值,指出 CollectionBase 是否有固定的大小。 (繼承來源 CollectionBase) |
IList.IsReadOnly |
取得值,指出 CollectionBase 是否唯讀。 (繼承來源 CollectionBase) |
IList.Item[Int32] |
在指定的索引位置上取得或設定項目。 (繼承來源 CollectionBase) |
IList.Remove(Object) |
從 CollectionBase 移除特定物件之第一個符合的元素。 (繼承來源 CollectionBase) |
擴充方法
Cast<TResult>(IEnumerable) |
將 IEnumerable 的項目轉換成指定的型別。 |
OfType<TResult>(IEnumerable) |
根據指定的型別來篩選 IEnumerable 的項目。 |
AsParallel(IEnumerable) |
啟用查詢的平行化作業。 |
AsQueryable(IEnumerable) |
將 IEnumerable 轉換成 IQueryable。 |