You are developing an application that includes a method named SendMessage.
You need to ensure that the SendMessage() method is called with the required parameters.
Which two code segments can you use to achieve this goal? (Each correct answer presents a complete
solution. Choose two.)
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Explanation:
D: ExpandoObject
Represents an object whose members can be dynamically added and removed at run time.
/ The ExpandoObject class enables you to add and delete members of its instances at run time and also to set
and get values of these members. This class supports dynamic binding, which enables you to use standard
syntax like sampleObject.sampleMember instead of more complex syntax like sampleObject.GetAttribute
(“sampleMember”).
/ You can pass instances of the ExpandoObject class as parameters. Note that these instances are treated as
dynamic objects in C# and late-bound objects in Visual Basic. This means that you do not have IntelliSense for
object members and you do not receive compiler errors when you call non-existent members. If you call a
member that does not exist, an exception occurs.
Note:
* Visual C# 2010 introduces a new type, dynamic. The type is a static type, but an object of type dynamic
bypasses static type checking. In most cases, it functions like it has type object. At compile time, an element
that is typed as dynamic is assumed to support any operation. Therefore, you do not have to be concerned
about whether the object gets its value from a COM API, from a dynamic language such as IronPython, from
the HTML Document Object Model (DOM), from reflection, or from somewhere else in the program. However, if
the code is not valid, errors are caught at run time.