我想用單個參數調用一個函數。我想通過Action Delegate調用它,但得到錯誤消息「不是所有的代碼路徑都返回一個值」。錯誤:行動委託「不是所有的路徑返回值」
我試過了,我可以用無參數功能來做到這一點。我
{
.... //Getting string from the selected item in ListBox.
Dispatcher.BeginInvoke(new Action<string>(displayText(myTextBlock.Text)));
}
private Action<string> displayText(string p)
{
MessageBox.Show(p);
}
你能幫我。
你'displayText'方法不返回'行動'。 –
2014-10-03 03:42:45
我想要做的就是調用一個沒有返回值的參數化函數。使用我的上述過程,我只能創建Action或Func對象,並選擇Action,因爲在我的代碼中,我不需要返回值。有什麼建議麼 ? – user3571361 2014-10-03 03:51:33
謝謝,我明白了你的觀點。 – user3571361 2014-10-03 04:31:12