You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a custom control named OrderForm.
You write the following code segment.
public delegate void CheckOrderFormEventHandler(EventArgs e);
private static readonly object CheckOrderFormKey = new object();
public event CheckOrderFormEventHandler CheckOrderForm {
add {
Events.AddHandler(CheckOrderFormKey, value);
}
remove {
Events.RemoveHandler(CheckOrderFormKey,
value);
}
}
You need to provide a method that enables the OrderForm control to raise the CheckOrderForm event.
Which code segment should you use?
A.
protected virtual void OnCheckOrderForm(EventArgs e) {
CheckOrderFormEventHandler checkOrderForm = (CheckOrderFormEventHandler)Events[typeof(CheckOrderFormEventHandler)];
if (checkOrderForm != null) checkOrderForm(e);
}
B.
protected virtual void OnCheckOrderForm(EventArgs e) {
CheckOrderFormEventHandler checkOrderForm = Events[CheckOrderFormKey] as CheckOrderFormEventHandler;
if (checkOrderForm != null) checkOrderForm(e);
}
C.
CheckOrderFormEventHandler checkOrderForm = new CheckOrderFormEventHandler(checkOrderFormCallBack);
protected virtual void OnCheckOrderForm(EventArgs e) {
if (checkOrderForm != null) checkOrderForm(e);
}
D.
CheckOrderFormEventHandler checkOrderForm = new CheckOrderFormEventHandler(checkOrderFormCallBack);
protected virtual void OnCheckOrderForm(EventArgs e) {
if (checkOrderForm != null) RaiseBubbleEvent(checkOrderForm, e);
}