ArrayList 建構函式

定義

初始化 ArrayList 類別的新執行個體。

多載

ArrayList()

初始化 ArrayList 類別的新執行個體,這個執行個體為空白且具有預設的初始容量。

ArrayList(ICollection)

初始化 ArrayList 類別的新執行個體,其含有從指定的集合複製過來的項目且具有與複製項目數一樣的初始容量。

ArrayList(Int32)

為具有指定初始容量且為空的 ArrayList 類別,初始化新的執行個體。

ArrayList()

來源:
ArrayList.cs
來源:
ArrayList.cs
來源:
ArrayList.cs

初始化 ArrayList 類別的新執行個體,這個執行個體為空白且具有預設的初始容量。

public:
 ArrayList();
public ArrayList ();
Public Sub New ()

備註

ArrayList 容量是 可以保留的項目 ArrayList 數目。 當元素新增至 ArrayList時,重新配置內部數位會自動增加容量。

如果可以估計集合的大小,則指定初始容量就不需要在將元素加入 至 ArrayList時執行一些重設大小作業。

此建構函式是作業 O(1)

另請參閱

適用於

ArrayList(ICollection)

來源:
ArrayList.cs
來源:
ArrayList.cs
來源:
ArrayList.cs

初始化 ArrayList 類別的新執行個體,其含有從指定的集合複製過來的項目且具有與複製項目數一樣的初始容量。

public:
 ArrayList(System::Collections::ICollection ^ c);
public ArrayList (System.Collections.ICollection c);
new System.Collections.ArrayList : System.Collections.ICollection -> System.Collections.ArrayList
Public Sub New (c As ICollection)

參數

c
ICollection

ICollection,要將其項目複製至新的清單。

例外狀況

cnull

c 是多維度陣列。

備註

ArrayList 容量是 可以保留的項目 ArrayList 數目。 當元素新增至 ArrayList時,重新配置內部數位會自動增加容量。

如果可以估計集合的大小,則指定初始容量就不需要在將元素加入 至 ArrayList時執行一些重設大小作業。

專案會以 所讀取IEnumeratorICollection的順序複製到 ArrayList 上。

此建構函式是作業 O(n) ,其中 n 是中的 c項目數目。

另請參閱

適用於

ArrayList(Int32)

來源:
ArrayList.cs
來源:
ArrayList.cs
來源:
ArrayList.cs

為具有指定初始容量且為空的 ArrayList 類別,初始化新的執行個體。

public:
 ArrayList(int capacity);
public ArrayList (int capacity);
new System.Collections.ArrayList : int -> System.Collections.ArrayList
Public Sub New (capacity As Integer)

參數

capacity
Int32

新清單一開始能夠儲存的項目數目。

例外狀況

capacity 小於零。

備註

ArrayList 容量是 可以保留的項目 ArrayList 數目。 當元素新增至 ArrayList時,重新配置內部數位會自動增加容量。

如果可以估計集合的大小,則指定初始容量就不需要在將元素加入 至 ArrayList時執行一些重設大小作業。

此建構函式是作業 O(n) ,其中 ncapacity

另請參閱

適用於