CodeDirectiveCollection 類別

定義

表示 CodeDirective 物件的集合。Represents a collection of CodeDirective objects.

public ref class CodeDirectiveCollection : System::Collections::CollectionBase
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeDirectiveCollection : System.Collections.CollectionBase
type CodeDirectiveCollection = class
    inherit CollectionBase
Public Class CodeDirectiveCollection
Inherits CollectionBase
繼承
CodeDirectiveCollection
屬性

範例

下列程式碼範例示範如何使用CodeDirectiveCollection類別的成員。The following code example shows the use of the members of the CodeDirectiveCollection class.

// Creates an empty CodeDirectiveCollection.
CodeDirectiveCollection collection = new CodeDirectiveCollection();

// Adds a CodeDirective to the collection.
collection.Add(new CodeRegionDirective(CodeRegionMode.Start, "Region1"));

// Adds an array of CodeDirective objects to the collection.
CodeDirective[] directives = { 
    new CodeRegionDirective(CodeRegionMode.Start,"Region1"), 
    new CodeRegionDirective(CodeRegionMode.End,"Region1") };
collection.AddRange(directives);

// Adds a collection of CodeDirective objects to the collection.
CodeDirectiveCollection directivesCollection = new CodeDirectiveCollection();
directivesCollection.Add(new CodeRegionDirective(CodeRegionMode.Start, "Region2"));
directivesCollection.Add(new CodeRegionDirective(CodeRegionMode.End, "Region2"));
collection.AddRange(directivesCollection);

// Tests for the presence of a CodeDirective in the 
// collection, and retrieves its index if it is found.
CodeDirective testDirective = new CodeRegionDirective(CodeRegionMode.Start, "Region1");
int itemIndex = -1;
if (collection.Contains(testDirective))
    itemIndex = collection.IndexOf(testDirective);

// Copies the contents of the collection beginning at index 0 to the specified CodeDirective array.
// 'directives' is a CodeDirective array.
collection.CopyTo(directives, 0);

// Retrieves the count of the items in the collection.
int collectionCount = collection.Count;

// Inserts a CodeDirective at index 0 of the collection.
collection.Insert(0, new CodeRegionDirective(CodeRegionMode.Start, "Region1"));

// Removes the specified CodeDirective from the collection.
CodeDirective directive = new CodeRegionDirective(CodeRegionMode.Start, "Region1");
collection.Remove(directive);

// Removes the CodeDirective at index 0.
collection.RemoveAt(0);
        ' Creates an empty CodeDirectiveCollection.
        Dim collection As New CodeDirectiveCollection()
        ' Adds a CodeDirective to the collection.
        collection.Add(New CodeRegionDirective(CodeRegionMode.Start, "Region1"))
        ' Adds an array of CodeDirective objects to the collection.
        Dim directives As CodeDirective() = {New CodeRegionDirective(CodeRegionMode.Start, "Region1"), New CodeRegionDirective(CodeRegionMode.End, "Region1")}
        collection.AddRange(directives)

        ' Adds a collection of CodeDirective objects to the collection.
        Dim directivesCollection As New CodeDirectiveCollection()
        directivesCollection.Add(New CodeRegionDirective(CodeRegionMode.Start, "Region2"))
        directivesCollection.Add(New CodeRegionDirective(CodeRegionMode.End, "Region2"))
        collection.AddRange(directivesCollection)
        ' Tests for the presence of a CodeDirective in the 
        ' collection, and retrieves its index if it is found.
        Dim testDirective = New CodeRegionDirective(CodeRegionMode.Start, "Region1")
        Dim itemIndex As Integer = -1
        If collection.Contains(testDirective) Then
            itemIndex = collection.IndexOf(testDirective)
        End If
        ' Copies the contents of the collection beginning at index 0 to the specified CodeDirective array.
        ' 'directives' is a CodeDirective array.
        collection.CopyTo(directives, 0)
        ' Retrieves the count of the items in the collection.
        Dim collectionCount As Integer = collection.Count
        ' Inserts a CodeDirective at index 0 of the collection.
        collection.Insert(0, New CodeRegionDirective(CodeRegionMode.Start, "Region1"))
        ' Removes the specified CodeDirective from the collection.
        Dim directive = New CodeRegionDirective(CodeRegionMode.Start, "Region1")
        collection.Remove(directive)
        ' Removes the CodeDirective at index 0.
        collection.RemoveAt(0)
    
    End Sub
End Class

備註

CodeDirectiveCollection 類別提供可用來儲存一組 CodeDirective 物件的簡單集合物件。The CodeDirectiveCollection class provides a simple collection object that can be used to store a set of CodeDirective objects.

建構函式

CodeDirectiveCollection()

初始化 CodeDirectiveCollection 類別的新執行個體。Initializes a new instance of the CodeDirectiveCollection class.

CodeDirectiveCollection(CodeDirective[])

使用指定陣列中的程式碼指示詞物件,初始化 CodeDirectiveCollection 類別的新執行個體。Initializes a new instance of the CodeDirectiveCollection class with the code directive objects in the specified array.

CodeDirectiveCollection(CodeDirectiveCollection)

使用指定程式碼指示詞集合中的項目,初始化 CodeDirectiveCollection 類別的新執行個體。Initializes a new instance of the CodeDirectiveCollection class with the elements in the specified code directive collection.

屬性

Capacity

取得或設定 CollectionBase 可包含的項目數目。Gets or sets the number of elements that the CollectionBase can contain.

(繼承來源 CollectionBase)
Count

取得包含在 CollectionBase 執行個體中的項目數目。Gets the number of elements contained in the CollectionBase instance. 這個屬性無法覆寫。This property cannot be overridden.

(繼承來源 CollectionBase)
InnerList

取得包含 ArrayList 執行個體中之元素清單的 CollectionBaseGets an ArrayList containing the list of elements in the CollectionBase instance.

(繼承來源 CollectionBase)
Item[Int32]

取得或設定位於集合中所指定索引處的 CodeDirective 物件。Gets or sets the CodeDirective object at the specified index in the collection.

List

取得包含 IList 執行個體中之元素清單的 CollectionBaseGets an IList containing the list of elements in the CollectionBase instance.

(繼承來源 CollectionBase)

方法

Add(CodeDirective)

將指定的 CodeDirective 物件加入至集合。Adds the specified CodeDirective object to the collection.

AddRange(CodeDirective[])

CodeDirective 物件的陣列加入集合結尾。Adds an array of CodeDirective objects to the end of the collection.

AddRange(CodeDirectiveCollection)

將指定的 CodeDirectiveCollection 物件內容加入集合的結尾。Adds the contents of the specified CodeDirectiveCollection object to the end of the collection.

Clear()

CollectionBase 執行個體移除所有的物件。Removes all objects from the CollectionBase instance. 無法覆寫這個方法。This method cannot be overridden.

(繼承來源 CollectionBase)
Contains(CodeDirective)

取得值,指出集合是否包含指定的 CodeDirective 物件。Gets a value indicating whether the collection contains the specified CodeDirective object.

CopyTo(CodeDirective[], Int32)

複製集合的內容至指定索引開頭的一維陣列。Copies the contents of the collection to a one-dimensional array beginning at the specified index.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetEnumerator()

傳回可逐一查看 CollectionBase 執行個體的列舉值。Returns an enumerator that iterates through the CollectionBase instance.

(繼承來源 CollectionBase)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IndexOf(CodeDirective)

取得指定 CodeDirective 物件在集合中的索引 (如果它存在於集合中)。Gets the index in the collection of the specified CodeDirective object, if it exists in the collection.

Insert(Int32, CodeDirective)

將指定的 CodeDirective 物件插入至集合中所指定索引處。Inserts the specified CodeDirective object into the collection at the specified index.

MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnClear()

在清除 CollectionBase 執行個體的內容之後,執行額外的自訂處理序。Performs additional custom processes when clearing the contents of the CollectionBase instance.

(繼承來源 CollectionBase)
OnClearComplete()

在清除 CollectionBase 執行個體的內容後,執行額外的自訂處理序。Performs additional custom processes after clearing the contents of the CollectionBase instance.

(繼承來源 CollectionBase)
OnInsert(Int32, Object)

在將新的元素插入至 CollectionBase 執行個體前,執行額外的自訂處理序。Performs additional custom processes before inserting a new element into the CollectionBase instance.

(繼承來源 CollectionBase)
OnInsertComplete(Int32, Object)

在將新的元素插入至 CollectionBase 執行個體後,執行額外的自訂處理序。Performs additional custom processes after inserting a new element into the CollectionBase instance.

(繼承來源 CollectionBase)
OnRemove(Int32, Object)

當從 CollectionBase 執行個體移除元素時,執行額外的自訂處理序。Performs additional custom processes when removing an element from the CollectionBase instance.

(繼承來源 CollectionBase)
OnRemoveComplete(Int32, Object)

在從 CollectionBase 執行個體移除元素後,執行額外的自訂處理序。Performs additional custom processes after removing an element from the CollectionBase instance.

(繼承來源 CollectionBase)
OnSet(Int32, Object, Object)

CollectionBase 執行個體中設定數值前,執行額外的自訂處理序。Performs additional custom processes before setting a value in the CollectionBase instance.

(繼承來源 CollectionBase)
OnSetComplete(Int32, Object, Object)

CollectionBase 執行個體中設定數值後,執行額外的自訂處理序。Performs additional custom processes after setting a value in the CollectionBase instance.

(繼承來源 CollectionBase)
OnValidate(Object)

當驗證數值時,執行額外的自訂處理序。Performs additional custom processes when validating a value.

(繼承來源 CollectionBase)
Remove(CodeDirective)

從集合中移除指定的 CodeDirective 物件。Removes the specified CodeDirective object from the collection.

RemoveAt(Int32)

移除 CollectionBase 執行個體之指定索引的元素。Removes the element at the specified index of the CollectionBase instance. 這個方法不可覆寫。This method is not overridable.

(繼承來源 CollectionBase)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從目標陣列的指定索引開始,將整個 CollectionBase 複製到相容的一維 ArrayCopies the entire CollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array.

(繼承來源 CollectionBase)
ICollection.IsSynchronized

取得值,這個值表示對 CollectionBase 的存取是否同步 (安全執行緒)。Gets a value indicating whether access to the CollectionBase is synchronized (thread safe).

(繼承來源 CollectionBase)
ICollection.SyncRoot

取得可用以同步存取 CollectionBase 的物件。Gets an object that can be used to synchronize access to the CollectionBase.

(繼承來源 CollectionBase)
IList.Add(Object)

將物件加入至 CollectionBase 的末端。Adds an object to the end of the CollectionBase.

(繼承來源 CollectionBase)
IList.Contains(Object)

判斷 CollectionBase 是否含有特定元素。Determines whether the CollectionBase contains a specific element.

(繼承來源 CollectionBase)
IList.IndexOf(Object)

搜尋指定的 Object,並傳回在整個 CollectionBase 中第一個符合項目之以零為起始的索引。Searches for the specified Object and returns the zero-based index of the first occurrence within the entire CollectionBase.

(繼承來源 CollectionBase)
IList.Insert(Int32, Object)

將項目插入至 CollectionBase 中指定的索引位置。Inserts an element into the CollectionBase at the specified index.

(繼承來源 CollectionBase)
IList.IsFixedSize

取得值,指出 CollectionBase 是否有固定的大小。Gets a value indicating whether the CollectionBase has a fixed size.

(繼承來源 CollectionBase)
IList.IsReadOnly

取得值,指出 CollectionBase 是否唯讀。Gets a value indicating whether the CollectionBase is read-only.

(繼承來源 CollectionBase)
IList.Item[Int32]

在指定的索引位置上取得或設定項目。Gets or sets the element at the specified index.

(繼承來源 CollectionBase)
IList.Remove(Object)

CollectionBase 移除特定物件之第一個符合的元素。Removes the first occurrence of a specific object from the CollectionBase.

(繼承來源 CollectionBase)

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱