Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where did my ArrayList Go? Metro app

In my Windows 8 app written using Visual Studio 11 Express Beta, I cannot use the ArrayList. Here is my code:

using System.Collections;


ArrayList al = new ArrayList();

Compiler error:

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

Is this something new? I love ArrayLists :)

like image 672
Trey Balut Avatar asked May 29 '12 20:05

Trey Balut


2 Answers

For WinRT, they took out all of the non-generic collections - it's faster and makes your code more reliable. Use List<T> instead.

ps... this will not be your last time saying "why the heck did they take away that API?" while migrating to WinRT

like image 140
Robert Levy Avatar answered Nov 03 '22 16:11

Robert Levy


ArrayList is not available in .NET 4.5 for metro style apps. Use the generic version of List, if you need an object list, use List<object>.

For the .NET for metro style apps API reference, take a look here: http://msdn.microsoft.com/en-us/library/windows/apps/hh454064%28v=vs.110%29.aspx

like image 1
Carsten Schütte Avatar answered Nov 03 '22 16:11

Carsten Schütte