2016-08-09 69 views
0

我編寫了這個代碼private ArrayList articles = new ArrayList();,它只是不會編譯。 Visual Studio是給我這個錯誤:在System.Collections中找不到ArrayList類型

The type or namespace name 'ArrayList' could not be found (are you missing a using directive or an assembly reference?)

但我確信導入System.Collections命名空間。 我即使

System.Collections.ArrayList articles = new ArrayList(); 

但沒有成功嘗試無論是。感謝您的幫助

+1

System.Collections.ArrayList articles = new System.Collections.ArrayList(); 將在那裏是正確的語法。但是,如果你已經包含了一個適當的命名空間的使用語句,它肯定會奏效;唯一的問題可能是該組件在您的項目中根本沒有被引用。 – Bogey

+0

這裏檢查定義和示例https://msdn.microsoft.com/en-us/library/system.collections.arraylist(v=vs.110).aspx#Anchor_7 – Nkosi

+2

您是否使用Metro應用程序或UWP?然後,他們走了。改爲使用列表。 –

回答

-1
System.Collections.ArrayList articles = new System.Collections.ArrayList(); 

這是正確的語法

+0

自動完成功能甚至不會在我輸入'System.Collections.Arr'時建議'ArrayList',然後按Ctrl + Tab –

0

如果您使用的框架4.0或更高版本的ArrayList()不available.You需要使用現有的泛型列表

+0

最後他們移除了'ArrayList'。 (我錯過了備忘錄)。我厭倦了「高手」''''''程序員使用'ArrayList'。 – ja72

0
List<List Item> list = new List<List Item>(); 

你可以使用此代碼的.net版本高於4.0。 *避免列表和項目之間的空格<> 在兩側...