Code:
hi there there is i have pasted a code the problem i have mentioned in the end after the code. //this is the argumentevent classi have made namespace argumentsevents { delegate void myeventhandler(object source , myeventargs arg); class eventclass { myeventargs o = new myeventargs(); public event myeventhandler anevent; public void furqan(object source, myeventargs arg) { arg.name = "faizan"; Console.WriteLine(arg.name + "ahmed here"); Console.WriteLine(); } public void furqan1(object source, myeventargs arg) { arg.name = "furqan"; Console.WriteLine(arg.name + "ahmed here"); } public void fire() { if (anevent != null) { anevent(this,o);//problem is here i have mentioned at the end } } } } //here is the class inherited by "eventargs" namespace argumentsevents { class myeventargs:EventArgs { public string name; } } //this is the main namespace argumentsevents { class Program { static void Main(string[] args) { eventclass ob = new eventclass(); ob.anevent += ob.furqan; ob.anevent += ob.furqan1; ob.fire(); } } } //now the problem THE THING IS THAT IN THE "ARGUMENTEVENT" CLASS AND IN THE FIRE METHOD I HAVE USED "anevent(this,o) " I USED THIS B/C THE EVENT IS CREATED IN THE SAME CLASS WHERE THERE IS THE FIRE METHOD THATS WHY I USED EVENT.SUPPOSE I MADE THE EVENT IN "MYEVENTARGS" CLASS THEN IN THE FIRE EVENT AND INSTEAD OF PASSSSING THIS WHAT I WILL PASS "anevent(???,o) "
Comment