I am trying to create an ArrayList of instances from another class in my program. In my case the class I am trying to create an ArrayList of is called record with the parameters firstname, lastname, and email. I have created another class called emailList and I am trying to instantiate the array list there. I am getting the error "The non-generic type 'ArrayList' cannot be used with type arguments".
Here is the code I have to create record objects in the Record class:
public class Record
{
private String firstname;
private String lastname;
private String email;
public Record(String firstNameIn, String lastNameIn, String emailIn)
{
firstname = firstNameIn;
lastname = lastNameIn;
email = emailIn;
}
In the emailList class I am trying to create an ArrayList in the emailList class using:
ArrayList<Record> eList = new ArrayList<Record>;
ArrayListin .NET, so instead ofArrayList<Record>you probably wantList<Record>. Stay away from the oldArrayList.var myArray = new Record[3]; myArray[0] = new Record("first", "last", "e-mail");List<T>uses an array to store items which is expanded when the list reaches its capacity, e.g.:var myList = new List<Record>(); myList.Add(new Record("first", "last", "e-mail"));