string strUserId = txtUser.Text; ArrayList list = Application.Get("GLOBAL_USER_LIST") as ArrayList; if (list == null) { list = new ArrayList(); } for (int i = 0; i < list.Count; i++) { if (strUserId == (list as string)) { //已经登录了,提示错误信息 lblError.Text = "此用户已经登录"; return; } } list.Add(strUserId); Application.Add("GLOBAL_USER_LIST", list);