subscribing an event to a class object before initializing it.
Posted
by GN
on Stack Overflow
See other posts from Stack Overflow
or by GN
Published on 2010-04-21T14:05:44Z
Indexed on
2010/04/21
14:13 UTC
Read the original article
Hit count: 166
c#
I have two classes class A and B.I have a delegate n event published in class B.The class B object is declared in class A.All he functionality dependes on the parameterised constru ctor of class B. Before initializing the object of class B i need to subscibe the event for it.how to do it? e.g
public class B
{
public delegate void myDel(string);
public event myDel myEvent;
B(object obj)
{
-----------------
------------------
}
}
class A
{
A objA;
class XYZ objXYZ;
void func()
{
objA.myEvent+=new myDel();
objA=new A(objXYZ); // hw to attain this?
}
}
© Stack Overflow or respective owner