Arraylist to store objects?

  • Thread starter Thread starter C Downey
  • Start date Start date
C

C Downey

Is there a way I can use the arraylist to store objects? I am trying to get
my function to return an arraylist of my objects but I keep getting
"System.NullReferenceException: Object reference not set to an instance of
an object" errors.

Any help would be greatly appreciated

Eg:
Dim alAs ArrayList

Dim report As New ReportClass()

Do While dr.Read

report = New ReportClass()

report.ID = dr("id")

report.ID = dr("otherstuff")

al.Add(report)

Loop
 
You have to create a new ArrayList first (e.g. new ArrayList()). Declaring
a variable does not necessarily create the object.
 
Back
Top