Hi
I have a question about events in C#.
In C#, we declare an event like this.
public delegate void EventHandlerA()
public class A
{
public event EventHandlerA eventObject = null;
private void SomeMethod()
{
if (eventObject != null)
{
eventObject();
}
}
}
class ClientOfClassA
{
ClassA objClassA = new ClassA();
objClassA.eventObject += new EventHandlerA(someFunctionOfClient)
}
My questiion is
When the user created an instance of classA, the classA.eventObject is
set to null. Immidiately after that the user hooks to the event by
executing += operator. If the object is null, why an exception is NOT
thrown when we execute += operator on a null object.
Best regards
Amit