You are developing an application that includes the following code segment. (Line numbers are
included for reference only.)
You need to ensure that the DoWork(Widget widget) method runs.
With which code segment should you replace line 24?
A.
DoWork((Widget)o);
B.
DoWork(new Widget(o));
C.
DoWork(o is Widget);
D.
DoWork((ItemBase)o);
A
O = new Widget() is an widening conversion so a program make the conversion implicitly. Every Widget is an object
(widget)o is a narrowing conversion. o is object variable but references a widget object. because o is an object, you can convert it back to a widget variable. converting from object to widget is narrowing conversion(more specific) so the code needs the widget cast operator