我试图改变一个项目一个变量的值:不能从一个项目发送变量的更新值到另一个在同一个解决方案
public string test;
public void Test (string _result)
{
test = _result;
//here i want to update the value of my variable
}
//Below there is a condition from one of my methods
if (result == 0)
{
Test(_client.ErrorText(result));
}
现在我想收到此变量在xaml.cs中:
private void AddString (object sender, RoutedEventArgs e)
{
_test = test
ListBox.Items.Add(_test);
}
因此,程序只将默认值添加到ListBox中。之后,即使Test()方法中的变量已更改,添加到ListBox的值仍然相同。 任何想法?
林不知道这是问题,因为他已经调用Listbox.Items.add – sTrenat
我已经根据您的建议进行了修改,它运作良好。谢谢 – BonnRon