2016-08-09 48 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。 *避免列表和项目之间的空格<> 在两侧...