问题描述
大家好,
我想将列表项传递给一个类到另一个类。我用过static关键字。但现在,当应用程序运行时仍然存在旧的变量。
实际上我有一个带复选框的列表视图。选中复选框后,单击一个按钮。然后弹出另一个窗口页面,其中包含关于每个Parent_File_Name和UserId的listview。我面临的问题是,在运行这个windows应用程序后,再次点击该按钮,静态变量包含整个列表项。怎么办呢?你能帮我吗?
请帮帮我......
我尝试了什么:
在第一堂课,
Hello everyone,
I want to pass list items to one class to anther class. I have used static keyword. But now, when the application is running still old variable is there.
Actually I have a listview with checkboxes. After checked checkboxes then click a button. Then popup another window page that contain listview with respect to each Parent_File_Name and UserId . I am facing the issue is, after running this windows apps then many time click on the button again both static variable contain whole list items. How can do this? Can you get me?
Please help me...
What I have tried:
In 1st class,
foreach (DocumentsUser item in listView1.SelectedItems)
{
ImgName.Add(item.Parent_File_Name);
UserId.Add((int)item.UserId);
}
private static List imgName = new List();
public static List ImgName { get { return imgName; } }
private static List userId = new List();
public static List UserId { get { return userId; } }
第二课拿这些静态变量,
2nd class taking those static variables,
foreach (var userId in Qscan.UC_FileMgmt.UserId)
{
foreach (var imgName in Qscan.UC_FileMgmt.ImgName)
{
推荐答案
这篇关于如何从静态类C#中删除旧值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!