CodeTypeDeclarationCollection 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示 CodeTypeDeclaration 物件的集合。
public ref class CodeTypeDeclarationCollection : System::Collections::CollectionBase
public class CodeTypeDeclarationCollection : System.Collections.CollectionBase
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeTypeDeclarationCollection : System.Collections.CollectionBase
type CodeTypeDeclarationCollection = class
inherit CollectionBase
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeTypeDeclarationCollection = class
inherit CollectionBase
Public Class CodeTypeDeclarationCollection
Inherits CollectionBase
- 繼承
- 屬性
範例
下列範例將示範如何使用 CodeTypeDeclarationCollection 類別。 此範例會建立 類別的新實例,並使用數種方法將 語句加入集合、傳回其索引,以及在特定索引點加入或移除屬性。
// Creates an empty CodeTypeDeclarationCollection.
CodeTypeDeclarationCollection^ collection = gcnew CodeTypeDeclarationCollection;
// Adds a CodeTypeDeclaration to the collection.
collection->Add( gcnew CodeTypeDeclaration( "TestType" ) );
// Adds an array of CodeTypeDeclaration objects to the collection.
array<CodeTypeDeclaration^>^declarations = {gcnew CodeTypeDeclaration( "TestType1" ),gcnew CodeTypeDeclaration( "TestType2" )};
collection->AddRange( declarations );
// Adds a collection of CodeTypeDeclaration objects to the
// collection.
CodeTypeDeclarationCollection^ declarationsCollection = gcnew CodeTypeDeclarationCollection;
declarationsCollection->Add( gcnew CodeTypeDeclaration( "TestType1" ) );
declarationsCollection->Add( gcnew CodeTypeDeclaration( "TestType2" ) );
collection->AddRange( declarationsCollection );
// Tests for the presence of a CodeTypeDeclaration in the
// collection, and retrieves its index if it is found.
CodeTypeDeclaration^ testDeclaration = gcnew CodeTypeDeclaration( "TestType" );
int itemIndex = -1;
if ( collection->Contains( testDeclaration ) )
itemIndex = collection->IndexOf( testDeclaration );
// Copies the contents of the collection, beginning at index 0,
// to the specified CodeTypeDeclaration array.
// 'declarations' is a CodeTypeDeclaration array.
collection->CopyTo( declarations, 0 );
// Retrieves the count of the items in the collection.
int collectionCount = collection->Count;
// Inserts a CodeTypeDeclaration at index 0 of the collection.
collection->Insert( 0, gcnew CodeTypeDeclaration( "TestType" ) );
// Removes the specified CodeTypeDeclaration from the collection.
CodeTypeDeclaration^ declaration = gcnew CodeTypeDeclaration( "TestType" );
collection->Remove( declaration );
// Removes the CodeTypeDeclaration at index 0.
collection->RemoveAt( 0 );
// Creates an empty CodeTypeDeclarationCollection.
CodeTypeDeclarationCollection collection = new CodeTypeDeclarationCollection();
// Adds a CodeTypeDeclaration to the collection.
collection.Add( new CodeTypeDeclaration("TestType") );
// Adds an array of CodeTypeDeclaration objects to the collection.
CodeTypeDeclaration[] declarations = { new CodeTypeDeclaration("TestType1"), new CodeTypeDeclaration("TestType2") };
collection.AddRange( declarations );
// Adds a collection of CodeTypeDeclaration objects to the
// collection.
CodeTypeDeclarationCollection declarationsCollection = new CodeTypeDeclarationCollection();
declarationsCollection.Add( new CodeTypeDeclaration("TestType1") );
declarationsCollection.Add( new CodeTypeDeclaration("TestType2") );
collection.AddRange( declarationsCollection );
// Tests for the presence of a CodeTypeDeclaration in the
// collection, and retrieves its index if it is found.
CodeTypeDeclaration testDeclaration = new CodeTypeDeclaration("TestType");
int itemIndex = -1;
if( collection.Contains( testDeclaration ) )
itemIndex = collection.IndexOf( testDeclaration );
// Copies the contents of the collection, beginning at index 0,
// to the specified CodeTypeDeclaration array.
// 'declarations' is a CodeTypeDeclaration array.
collection.CopyTo( declarations, 0 );
// Retrieves the count of the items in the collection.
int collectionCount = collection.Count;
// Inserts a CodeTypeDeclaration at index 0 of the collection.
collection.Insert( 0, new CodeTypeDeclaration("TestType") );
// Removes the specified CodeTypeDeclaration from the collection.
CodeTypeDeclaration declaration = new CodeTypeDeclaration("TestType");
collection.Remove( declaration );
// Removes the CodeTypeDeclaration at index 0.
collection.RemoveAt(0);
' Creates an empty CodeTypeDeclarationCollection.
Dim collection As New CodeTypeDeclarationCollection()
' Adds a CodeTypeDeclaration to the collection.
collection.Add(New CodeTypeDeclaration("TestType"))
' Adds an array of CodeTypeDeclaration objects to the
' collection.
Dim declarations As CodeTypeDeclaration() = {New CodeTypeDeclaration("TestType1"), New CodeTypeDeclaration("TestType2")}
collection.AddRange(declarations)
' Adds a collection of CodeTypeDeclaration objects to the collection.
Dim declarationsCollection As New CodeTypeDeclarationCollection()
declarationsCollection.Add(New CodeTypeDeclaration("TestType1"))
declarationsCollection.Add(New CodeTypeDeclaration("TestType2"))
collection.AddRange(declarationsCollection)
' Tests for the presence of a CodeTypeDeclaration in the
' collection, and retrieves its index if it is found.
Dim testDeclaration As New CodeTypeDeclaration("TestType")
Dim itemIndex As Integer = -1
If collection.Contains(testDeclaration) Then
itemIndex = collection.IndexOf(testDeclaration)
End If
' Copies the contents of the collection, beginning at index 0,
' to the specified CodeTypeDeclaration array.
' 'declarations' is a CodeTypeDeclaration array.
collection.CopyTo(declarations, 0)
' Retrieves the count of the items in the collection.
Dim collectionCount As Integer = collection.Count
' Inserts a CodeTypeDeclaration at index 0 of the collection.
collection.Insert(0, New CodeTypeDeclaration("TestType"))
' Removes the specified CodeTypeDeclaration from the collection.
Dim declaration As New CodeTypeDeclaration("TestType")
collection.Remove(declaration)
' Removes the CodeTypeDeclaration at index 0.
collection.RemoveAt(0)
備註
CodeTypeDeclarationCollection 類別提供可用來儲存一組 CodeTypeDeclaration 物件的簡單集合物件。
建構函式
CodeTypeDeclarationCollection() |
初始化 CodeTypeDeclarationCollection 類別的新執行個體。 |
CodeTypeDeclarationCollection(CodeTypeDeclaration[]) |
初始化 CodeTypeDeclarationCollection 類別的新執行個體,這個執行個體包含 CodeTypeDeclaration 物件的指定陣列。 |
CodeTypeDeclarationCollection(CodeTypeDeclarationCollection) |
初始化 CodeTypeDeclarationCollection 類別的新執行個體,這個執行個體包含指定之來源集合的元素。 |
屬性
Capacity |
取得或設定 CollectionBase 可包含的項目數目。 (繼承來源 CollectionBase) |
Count |
取得 CollectionBase 執行個體中包含的元素數目。 這個屬性無法覆寫。 (繼承來源 CollectionBase) |
InnerList |
取得包含 ArrayList 執行個體中之元素清單的 CollectionBase。 (繼承來源 CollectionBase) |
Item[Int32] |
取得或設定位於集合中所指定索引處的 CodeTypeDeclaration 物件。 |
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。 |