我有這樣的:System.Action委託忽略參數?
public event Action<BaseCommodity> OnGatherActionSelected = delegate { };
gmp.OnGatherActionSelected += m_Worker.CharacterActions.StartGatherMaterials; // << takes a parameter
,但現在我想用事件來調用帶0參數
gmp.OnGatherActionSelected += ParentPanel.RedrawUI; // does not take parameters .. DOES NOT WORK :(
我怎麼能做到這一點的方法?
如果你想不帶參數的處理程序,你應該使用'Action'代替'行動' –
我主要需要的參數,只在一個單一的情況下,我想忽略的參數並調用方法...我無法相信,沒有辦法跳過參數 – Cxyda
因此,只要用'obj.YourEvent + = x => yourMethod();'來忽略它,就像Guffa和Charles提供的那樣。 –