开发者

Class being converted to 1-dimensional array

I am trying to write a class library and I am getting the following error: "Value of type 'WorkMateLib.Login' cannot be converted to '1-dimensional array of WorkMateLib.Login'"

The code of the classes is as follows:

Public Class Logins
    Public CurrentUser As Login()
    Public Sub New()
        CurrentUser = New Login()
    End Sub
    Public Function Authenticate(ByVal id As String, ByVal pw As String)
        Dim adpt As New WorkMateDataSetTableAdapters.LoginsTableAdapter
        For Each k As WorkMateDataSet.LoginsRow In adpt.GetDataByUserName(id)
            If String.Equals(k.UserPW, pw) Then
                CurrentUser = New Login(k.UserName, k.UserPW, k.UserType)
                Return CurrentUser
                Exit Function
            End If
        Next
        CurrentUser = Nothing
        Return Nothing
    End Function

End Class

Public Cl开发者_运维技巧ass Login
    Private _UserName As String
    Private _UserPW As String
    Private _UserType As String
    Property UserName
        Get
            Return _UserName
        End Get
        Set(value)
            _UserName = value
        End Set
    End Property
    Property UserPW
        Get
            Return _UserPW
        End Get
        Set(value)
            _UserPW = value
        End Set
    End Property
    Property UserType
        Get
            Return _UserType
        End Get
        Set(value)
            _UserType = value
        End Set
    End Property
    Public Sub New()
        UserName = ""
        UserPW = ""
        UserType = ""
    End Sub
    Public Sub New(ByVal Namee As String, ByVal pw As String, ByVal typee As String)
        UserName = Namee
        UserPW = pw
        UserType = typee
    End Sub

End Class

Thanks for the help in advance.


It should just be

Dim CurrentUser as Login

Adding the () to the end of the Type changes it to an Array of the Type.

You should really be declaring the variable as

Dim CurrentUser As Login = New Login

As this will instantiate an instance of the Login object and assign it to the CurrentUser Variable. Currently you are just creating a Variable that is a Login type but giving it no value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜