Don't use ArrayList!

arraylist, arrays, vb.net

Solution

Use generic lists instead. ArrayList is not typed, meaning that you can have a list with strings, numbers, +++. Rather you should use a generic list like this:

Dim list1 As New List(Of String) ' This beeing a list of string

The lists-class also allows you to expand the list on the fly, however, it also enforces typing which helps write cleaner code (you don't have to typecast) and code that is less prone to bugs.

ArrayList is gennerally speaking just a `List(Of Object)`.

Problem

People often tell me not to use ArrayList for making my arrays in VB.NET. I would like to hear opinions about that, why shouldn't I? What is the best method for creating and manipulating array contents, dimensions etc? Thanks.

Original source