VB.NET - 公共变量在函数之间不保持值

时间:2016-03-16 22:46:30

标签: vb.net wcf

我在VB.NET中有一个WCF服务。我目前的情况是,如果用户是否被记录,我想保留一个变量说明为true或false!

代码:

Public Property User_Logged As Boolean
Public Function Login(ByVal Username As String, ByVal Password As String) As Boolean Implements SQLOperator.Login
    ...
    If (Username = "root" and Password="test") Then
     User_Logged = True
     MsgBox(User_Logged)
    Else
     User_Logged = False
     MsgBox(User_Logged)
    End If
End Function

Public Function UserIsLogged() As Boolean Implements SQLOperator.UserIsLogged
    MsgBox("islogged: " & User_Logged)
End Function

在第二个函数中,变量输出为false,在第一个函数中,它输出为true。

0 个答案:

没有答案