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

What does this code print when the button is clicked, given that the field-like event 'Clicked' is assigned a multicast delegate of two handlers?

public class Button { public event Action Clicked; public void Press() { var snapshot = Clicked; snapshot?.Invoke(); } } // usage var b = new Button(); Action h1 = () => { Console.Write("A"); throw new Exception(); }; Action h2 = () => Console.Write("B"); b.Clicked += h1; b.Clicked += h2; try { b.Press(); } catch { Console.Write("X"); }