CodeNamespaceImportCollection 類別

定義

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

public ref class CodeNamespaceImportCollection : System::Collections::IList
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeNamespaceImportCollection : System.Collections.IList
type CodeNamespaceImportCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class CodeNamespaceImportCollection
Implements IList
繼承
CodeNamespaceImportCollection
屬性
實作

範例

下列範例示範CodeNamespaceImportCollection類別的某些成員。The following example demonstrates some of the members of the CodeNamespaceImportCollection class. 此範例會初始化類別的新實例, 並將CodeNamespaceImport物件加入其中, 並取得集合中的物件總數。The example initializes a new instance of the class, adds CodeNamespaceImport objects to it, and gets the total number of objects in the collection.

// Creates an empty CodeNamespaceImportCollection.
CodeNamespaceImportCollection^ collection =
   gcnew CodeNamespaceImportCollection;

// Adds a CodeNamespaceImport to the collection.
collection->Add( gcnew CodeNamespaceImport( "System" ) );

// Adds an array of CodeNamespaceImport objects to the collection.
array<CodeNamespaceImport^>^ Imports = {
   gcnew CodeNamespaceImport( "System" ),
   gcnew CodeNamespaceImport( "System.Drawing" )};
collection->AddRange( Imports );

// Retrieves the count of the items in the collection.
int collectionCount = collection->Count;
// Creates an empty CodeNamespaceImportCollection.
CodeNamespaceImportCollection collection = 
    new CodeNamespaceImportCollection();            			

// Adds a CodeNamespaceImport to the collection.
collection.Add( new CodeNamespaceImport("System") );

// Adds an array of CodeNamespaceImport objects to the collection.
CodeNamespaceImport[] Imports = { 
        new CodeNamespaceImport("System"),
        new CodeNamespaceImport("System.Drawing") };
collection.AddRange( Imports );

// Retrieves the count of the items in the collection.
int collectionCount = collection.Count;
' Creates an empty CodeNamespaceImportCollection.
Dim collection As New CodeNamespaceImportCollection()

' Adds a CodeNamespaceImport to the collection.
collection.Add(New CodeNamespaceImport("System"))

' Adds an array of CodeNamespaceImport objects to the collection.
Dim [Imports] As CodeNamespaceImport() = _
    {New CodeNamespaceImport("System"), _
    New CodeNamespaceImport("System.Drawing")}
collection.AddRange([Imports])

' Retrieves the count of the items in the collection.
Dim collectionCount As Integer = collection.Count

備註

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

建構函式

CodeNamespaceImportCollection()

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

屬性

Count

取得集合中的命名空間 (Namespace) 數目。Gets the number of namespaces in the collection.

Item[Int32]

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

方法

Add(CodeNamespaceImport)

CodeNamespaceImport 物件加入至集合。Adds a CodeNamespaceImport object to the collection.

AddRange(CodeNamespaceImport[])

將一組 CodeNamespaceImport 物件加入至集合中。Adds a set of CodeNamespaceImport objects to the collection.

Clear()

清除成員的集合。Clears the collection of members.

Equals(Object)

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

(繼承來源 Object)
GetEnumerator()

取得列舉集合成員的列舉值。Gets an enumerator that enumerates the collection members.

GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

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

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從特定的 ICollection 索引開始,將 Array 的項目複製到 ArrayCopies the elements of the ICollection to an Array, starting at a particular Array index.

ICollection.Count

取得 ICollection 中所包含的項目數。Gets the number of elements contained in the ICollection.

ICollection.IsSynchronized

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

ICollection.SyncRoot

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

IEnumerable.GetEnumerator()

傳回可逐一查看集合的列舉值。Returns an enumerator that can iterate through a collection.

IList.Add(Object)

將物件加入至 IListAdds an object to the IList.

IList.Clear()

IList 中移除所有項目。Removes all items from the IList.

IList.Contains(Object)

判斷 IList 是否包含特定值。Determines whether the IList contains a specific value.

IList.IndexOf(Object)

判斷 IList 中指定項目的索引。Determines the index of a specific item in the IList.

IList.Insert(Int32, Object)

將項目插入位於指定位置的 IListInserts an item in the IList at the specified position.

IList.IsFixedSize

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

IList.IsReadOnly

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

IList.Item[Int32]

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

IList.Remove(Object)

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

IList.RemoveAt(Int32)

移除 IList 中指定之索引處的項目。Removes the element at the specified index of the IList.

擴充方法

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.

適用於

另請參閱