I know this might be a trivial question, but I was just wondering whether there is any advantage of calling Button.PerformClick
rather than invoking the click event of a button directly. The MSDN documentation simply says:
Generates a Click event for a button.
Does this mean it simply does the same thing as calling the click event of the button or is there some other special advantage?
An external caller who knows nothing of the subscribed events cannot simply call the click handler - and events do not allow you to obtain information about subscribers. So this method allows separation of concerns, so that external callers can "play nice".
Additionally:
If you do know about the event-handler, and you aren't using polymorphism, and you don't care whether it is disabled, and you don't need to worry about event-handlers you don't already know about - then by all means : just call the event-handler method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With