Inside C# 4.0: dynamic typing, optional parameters, covariance and contravariance
Oct 31, 2008 at 10:59 PMI'm half way through, and I have a question.
Say you have the following:
dynamic x = ...
x.M(1,2,3,4,5,6,7,8,9,10);
x.M(1,2,3,4,5,6,7,8,9,"a string");
x.M(1,2,3,4,3.14159);
x.M(DateTime.Now);
Will the generated delegate check parameters one at a time? eg, like this:
if (param1Type == typeof(int))
{
if (param2Type == ...)
{
...
if (param5Type == int)
{...}
else if (param5Type == double)
{ ..}
} else if (param1Type == DateTime) {}
Or will it check each one repeatedly?
Also, will there be any sort of profile-guided optimisation in that delegate? Say that it notices x.M(DateTime) is called the most, will it reorder the tests?