Named Parameters Revisited in .Net 4.5

As most of you are aware of the fact that a lot of language and compiler changes has taken place due to the recent .Net release and there ought to be many issues, but all the issues will not surface until and unless you are recompiling your code. Once you recompile your code, these changes will get introduced, regardless of which framework you have targeted.

Today I am writing about one of the major changes that has happened in .Net 4.5.

In the earlier framework, the named and the optional parameter concept was introduced, but unfortunately it was implemented incorrectly. In essence, there was an issue with the evaluation order of the named parameter and it occurs only when you are using the methods as an argument.
Let's have a look at this snippet taken from the MSDN:
Expected output: A C B
Output in Visual Studio 2010: C B A
Output in Visual Studio 2012/2013: A C B
Hope by this time, you are convinced about this incorrectness. Please note, here the issue is with the named parameters and has nothing to do with the optional parameters. And this issue is with the Visual Studio 2010 compiler which is giving the unexpected results.

Reason - We are getting incorrect results because of the fact that the named parameters are being evaluated before the positional arguments. Whereas for both the named and the positional, it must evaluate from the left to the right. This was the bug in VS 2010 and it has been addressed in VS 2012.

This is unlikely to cause a problem in your code until and unless you are calling the methods in your argument list.

Suggestion - Avoid calling the methods in the argument list if the order of execution is important for your application.

Note: ref and out parameters may also suffer from side effects due to this change.