D
Darren
If I have a class that exposes a delegate (see following code), how do
other objects who wish to receive notifications be coded? What I mean
is the first object to receive notifications must create the delegate
by doing a 'new' whereas other objects just need to use += to add to
the delegate list. Is there a way of doing this without each class
testing whether to create the delegate first?
class ClassX
{
public delegate void MyDelegate(string x);
public MyDelegate OnDelegate;
...
}
class ReceivingDelegateNotifications
{
ClassX.OnDelegate = new ClassX.MyDelegate(MyMethod);
ClassX.OnDelegate += new ClassX.MyDelegate(MySecondMethod);
private void MyMethod(string y) {...}
private void MySecondMethod(string y) {...}
}
Thanks in advance,
Darren.
other objects who wish to receive notifications be coded? What I mean
is the first object to receive notifications must create the delegate
by doing a 'new' whereas other objects just need to use += to add to
the delegate list. Is there a way of doing this without each class
testing whether to create the delegate first?
class ClassX
{
public delegate void MyDelegate(string x);
public MyDelegate OnDelegate;
...
}
class ReceivingDelegateNotifications
{
ClassX.OnDelegate = new ClassX.MyDelegate(MyMethod);
ClassX.OnDelegate += new ClassX.MyDelegate(MySecondMethod);
private void MyMethod(string y) {...}
private void MySecondMethod(string y) {...}
}
Thanks in advance,
Darren.