我有一个方法:
FillListBox();
Run Code Online (Sandbox Code Playgroud)
我从不同的地方调用这个方法..但有时会发生,事情被加载了两次!
现在我正在尝试做类似的事情:
if (listBox.Items[1].ToString() == "hello")
{
DO NOT FILL
}
else
{
FILL
}
Run Code Online (Sandbox Code Playgroud)
这不行!:(
Fault: InvalidArgument=Value of '1' is not valid for 'index'.
Parameter name: index
Run Code Online (Sandbox Code Playgroud)
这样的事情:
if(listBox.Items.Contains("hello"))
{
DONT FILL
}
Run Code Online (Sandbox Code Playgroud)
不要工作:(
我能做什么?