I have such an example code:
static void Main()
{
dynamic dynamicObject = null;
object simpleObject = dynamicObject + new AnyClass();
Console.WriteLine(simpleObject);
}
class AnyClass
{
public override string ToString()
{
return "text";
}
}
Execution result is:
text
If I understood it correctly, then part dynamicObject + new AnyClass() calls the string concatenation, which return empty string for dynamicObject due to it refers to null, and new AnyClass() returns text. But there's no string argument, which is necessary to call ToString(). Why does it happens so? Why is an exception not being generated about the lack of implementation of the operation '+'?