Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC#events and observer patternSingle-choice MCQ

When raising an event using the classic null-check pattern (not the ?. operator), why is copying the event field to a local variable before invoking it the recommended idiom?

// Pattern A if (SomethingHappened != null) SomethingHappened(this, e); // Pattern B var handler = SomethingHappened; if (handler != null) handler(this, e);