Breaking changes in C# in Visual Studio 2012
Posted: (EET/GMT+2)
Now that the next version of the C# language is soon here along with Visual Studio 2012, it's time to prepare for some possible code changes due to changes in the compiler. Of course, this only applies to projects which you prefer to convert: continuing to use Visual Studio 2010 is of course an intermediate option while you prepare you code to be updated to Visual Studio 2012.
In any case, breaking changes in the next C# version are small, and are mainly related how foreach loops are handled inside lambda expressions and LINQ queries. For instance, if you have code similar to this, then your code might be a suspect to changes:
var methods = new List(); foreach (var word in new string[] { "hello", "world" }) { methods.Add(() => Console.Write(word + " ")); } methods[0](); methods[1]();
With Visual Studio 2010, this would output "world world", but with Visual Studio 2012, it would be more commonsense-wise "hello world".
Two other areas where your application might break are the resolution of named arguments in methods, and method overload resolution. However, after reading the documentation, both of these two are more or less corner cases in my opinion, but in any case, they are worth being aware of.
For full details, see MSDN.