我想以編程方式調用帶有事件的函數。字符串到事件
如何將字符串轉換爲一般事件?我的問題其實不知道如何做到這一點?
如何將str轉換爲事件?
str = "test1";
// UserControlsBackgroundEventArgs = EventArgs
EventArgs arg = (EventArgs)str; --> ?
UserControlsBackgroundOutput(str);
//function
private string CLICKNAME = "test0";
private void UserControlsBackgroundOutput(EventArgs e)
{
if (CLICKNAME == e.output)
return;
if (e.output == "test1"){}
}
錯誤解決: 我必須做的
UserControlsBackgroundEventArgs arg = new UserControlsBackgroundEventArgs(CLICKNAME);
代替
UserControlsBackgroundEventArgs arg = new (UserControlsBackgroundEventArgs)(CLICKNAME);
我們不知道什麼'UserControlsBackgroundEventArgs'是,這使得它很難幫助你...你的問題目前非常不清楚。請閱讀http://tinyurl.com/so-list(你甚至沒有試圖將字符串轉換爲*事件* - 你試圖將它轉換爲你的'UserControlsBackgroundEventArgs'類的一個實例,它不是' t事件... –
現在我所能說的就是'UserControlsBackgroundEventArgs'應該具有保存'str'值的屬性。你能給你的問題添加更多的上下文嗎?什麼是真實世界的用法? – Leri
「UserControlsBackgroundEventArgs = EventArgs」是什麼意思?它是同一個類嗎? – pascalhein