Here's a tricky one and maybe not the best way to do this so I'm open to suggestions.
I have a class with properties. One of the properties is of type ArrayList like so.....
Property DepartmentList() As ArrayList
Get
Return mcolDeptList
End Get
Set(ByVal value As ArrayList)
mcolDeptList = value
End Set
End Property
Ok so now I have a list of Departments in a DB table that I want to put into this property. This is what I'm doing......
............DB Code to get the departments
Dim objDepartment As clsDepartments
objDepartment = New clsDepartments
Dim arrList As New ArrayList
Do While objdatareader.Read
arrList.Add(objdatareader("name"))
Loop
'Add the new array object to the class.
objDepartment.DepartmentList.AddRange(arrList)'ERROR HERE
I am getting an error that I have not set the instance of an object and to use the "New" keyword. I cannot see how to use the new keyword on the class property.
Any help would be apperciated.
Ty
I have a class with properties. One of the properties is of type ArrayList like so.....
Property DepartmentList() As ArrayList
Get
Return mcolDeptList
End Get
Set(ByVal value As ArrayList)
mcolDeptList = value
End Set
End Property
Ok so now I have a list of Departments in a DB table that I want to put into this property. This is what I'm doing......
............DB Code to get the departments
Dim objDepartment As clsDepartments
objDepartment = New clsDepartments
Dim arrList As New ArrayList
Do While objdatareader.Read
arrList.Add(objdatareader("name"))
Loop
'Add the new array object to the class.
objDepartment.DepartmentList.AddRange(arrList)'ERROR HERE
I am getting an error that I have not set the instance of an object and to use the "New" keyword. I cannot see how to use the new keyword on the class property.
Any help would be apperciated.
Ty