c# - String to event -


i'm trying programmatically call function event.

how convert string event in general? problem not knowing how this?

how convert str event?

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"){} } 

error solved: had do

usercontrolsbackgroundeventargs arg = new usercontrolsbackgroundeventargs(clickname); 

instead of

usercontrolsbackgroundeventargs arg = new (usercontrolsbackgroundeventargs)(clickname); 

i've written code mimic code, find useful:

public class usercontrolsbackgroundeventargs {   public string output;    public usercontrolsbackgroundeventargs(string up)   {      output = up;   } }  public delegate void usercontrolsbackgroundoutputhandle(usercontrolsbackgroundeventargs e);  public class testevent {   public event usercontrolsbackgroundoutputhandle usercontrolsbackgroundoutput;    public void dosomethings()   {      // things       if (usercontrolsbackgroundoutput != null)      {         string str = "test1";          usercontrolsbackgroundeventargs arg = new usercontrolsbackgroundeventargs(str);         usercontrolsbackgroundoutput(arg); // you've done str, whitch makes me                                           // don't know event param      }   } }  public class test {   private testevent mytest;   private const string clickname = "whatever"; // don't know want here    public test()   {      mytest = new testevent();      mytest.usercontrolsbackgroundoutput += usercontrolsbackgroundoutput;   }    void usercontrolsbackgroundoutput(usercontrolsbackgroundeventargs e)   {      if (clickname == e.output)         return;       if (e.output == "test1")      {      }   } } 

Comments