F
Flare
Hi i have a qusstion about events and delegates. Especially the precis role
of the Event.
Eg. We have a class wich want to fire events so we declare:
public delegate void TestEventHandler(object sender, EventArgs arg);
public event TestEventHandler Test;
And fire the event with
if(Test != null)
Test(this, new EventArg());
Is the right:
Test is actually a MultiCast delgate? Debugger says it is! OK.
Buth then why use the event keyword in front of the Test and insted not
just:
public delegate void TestEventHandler(object sender, EventArgs arg);
public TestEventHandler Test;
And fire the event with
if(Test != null)
Test(this, new EventArg());
It work fine. Why do we need the event keyword? Clearly there is a reason.
Someone who can tell me?
reagards
Anders
of the Event.
Eg. We have a class wich want to fire events so we declare:
public delegate void TestEventHandler(object sender, EventArgs arg);
public event TestEventHandler Test;
And fire the event with
if(Test != null)
Test(this, new EventArg());
Is the right:
Test is actually a MultiCast delgate? Debugger says it is! OK.
Buth then why use the event keyword in front of the Test and insted not
just:
public delegate void TestEventHandler(object sender, EventArgs arg);
public TestEventHandler Test;
And fire the event with
if(Test != null)
Test(this, new EventArg());
It work fine. Why do we need the event keyword? Clearly there is a reason.
Someone who can tell me?
reagards
Anders