ArrayList inside Structure/Class
Is it not possible to use an ArrayList inside of a Structure or a Class?
I keep getting 'Object reference not set to instance of an object'
I am using New.
i.e.
Stucture ABC
Dim al as ArrayList
End Structure
Private Sub X()
Dim Struct1 as New ABC
Struct1.al.Add("anything")
End Sub
Re: ArrayList inside Structure/Class
It's because the arraylist hasn't been instanciated yet.
I'm not a 100% sure if you can do this inside a Structure, if not then use a Class instead.
VB Code:
Structure ABC
Public al as ArrayList = New ArrayList
End Structure
or
VB Code:
Structure ABC
Public al as ArrayList
Public Sub New()
al = New ArrayList
End Sub
End Structure
Re: ArrayList inside Structure/Class
Your first solution works for a class. Thanks grillkip.