我試圖改變一個項目一個變量的值:不能從一個項目發送變量的更新值到另一個在同一個解決方案
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