In answer to my other question How to send custom event message just after control instantiation? I read this:
if (ValueChanged != null)
{
ValueChanged(sender, e);
}
What is ValueChanged in the first case ? Not a function as in the second instruction ? How can the same symbol be used for both … and function ?
uPDATE after james’s answer: if ValueChanged is an Object, How can I call it as if it were a Method? Is it a syntactic sugar or alien syntax with some mysterious mechanism behind like calling ValueChanged.Invoke(sender, e); ?
ValueChanged is a multi-cast delegate, which is an object. If no one has subscribed to the event, it can be null, hence the check. If you want to avoid the check, you can define an empty delegate and assign it to the event.
You can now just call ValueChanged(sender, e) because ValueChanged can never be null.