Where is my ArrayList Go? Metro App

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

using System.Collections; ArrayList al = new ArrayList(); 

Compiler Error:

Could not find type name or namespace 'ArrayList' (do you miss using directive or assembly reference?)

This is something new? I like ArrayLists :)

+6
source share
5 answers

For WinRT, they got all non-common collections - it is faster and makes your code more reliable. Use the <T> list instead.

ps ... this is not your last time you said: "Why did they pick up this API?" when switching to WinRT

+13
source

EDIT

Given the documentation of ArrayList , it is available up to version 4.0. Check the version of the .NET Framework project. Given that you write Metro, this should be 4.5 (at least).

More information on this post:

How to use the ArrayList class in a subway-style class library project?

And the System.Collections namespace for Metro Style applications is missing an ArrayList type.

+1
source

ArrayList is not available in .NET 4.5 for metro-style applications. Use the generic version of List; if you need a list of objects, use List<object> .

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

+1
source

You cannot use ArrayList in a WinRT application, you will need to use List .

0
source

It depends on the version of the .NET Framework you are using. ArrayList is not supported in .Net 4.5.1. you should use the generic form List, List<T> instead of ArrayList as collection types.

Take a look here:

Is the <Object> list a good replacement for ArrayList?

and you can find out more here:

https://msdn.microsoft.com/en-us/library/41107z8a.aspx

0
source

Source: https://habr.com/ru/post/916947/


All Articles