我只是想创建一个函数来返回一组用户。但是,为了以后能够将项目添加到集合中,我使用了arrayList,但最后我得到了一个错误 Type ArrayList cannot be converted to 1-Dimensional array of Users
这是我的代码:
Function getDoctorsList() As Users()
Dim userCollection As New ArrayList
Dim sql = "SELECT * FROM '" + _tblName + "' WHERE usertype = 'doctor'"
Dim dr As SqlDataReader = dbHelper.ExecuteAndGetReader(sql)
While dr.Read
Dim user As New Users
user.Id = IIf(IsDBNull(dr("id")), 0, dr("id"))
user.UserName = IIf(IsDBNull(dr("username")), "", dr("username"))
user.UserNin = IIf(IsDBNull(dr("user_nin")), 0, dr("user_nin"))
user.UserType = IIf(IsDBNull(dr("usertype")), "", dr("usertype"))
user.Password = IIf(IsDBNull(dr("password")), "", dr("password"))
userCollection.Add(user)
End While
Return userCollection
End Function
如何解决此类问题?