So I need to use an ArrayList in C#. I looked it up in MSDN and they said I had to create a class, add System.Collections and Add
IList, ICollection, IEnumerable,
ICloneable to the class
class clsExample : IList, ICollection, IEnumerable, ICloneable;
then I tried to use my Arraylist. So I typed:
ArrayList myAL = new ArrayList();
But the problem is that when I try to add things to the array (myAL.Add(1, Example);) the code doesn't find the array (myAL) and underlines an error to it. Am I missing something?
Code:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
namespace WindowsFormsApplication7
{
[SerializableAttribute]
class clsAL : IList, ICollection, IEnumerable,
ICloneable
{
ArrayList AL = new ArrayList();
}
}
clsALclass here, so external code wouldn't see this private member.So I need to use an ArrayList in C#... and there was the first mistake. ArrayLists in C# are not good. Use a List<T> instead.