会话窗口形成了C#应用程序 [英] Session for windows forms application in c#

查看:128
本文介绍了会话窗口形成了C#应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是有为了记录日志的细节和注销多个用户可以根据应用程序的C#Windows任何会话。

is there any session for windows based application for c# in order to record details of log in in and log out for multiple users.

我试图使用声明静态变量。但它是不一样的类似会话。

i tried use declaring static variables. but it is not the same like session.

感谢。你的答案是非常赞赏。

thanks. your answer is very much appreciated.

推荐答案

有是在Windows窗体没有会话变量的概念。你可以做的是:

There is no concept of Session variables in windows forms. What you can do is:

创建一个保存用户名和密码,在应用程序所需要的任何其他变量的静态类

Create a Static class that holds the User name and password and any other variables needed across the application .

在你的情况下,它会是这样:

In your case it would be something like:

public static class LoginInfo
{
    public static string UserID;
}

现在你可以在你的代码的任何地方只需访问用户名:

Now you can access the UserID simply from anywhere in your code:

MessageBox.Show(LogInfo.UserID);



也可以设置登录后的值如

Or set the values after login like

LogInfo.UserID=TextBox1.Text;

这篇关于会话窗口形成了C#应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆