Why I can use Object Initializers in Visual Studio 2008 Windows projects, etc targeted to .NET 2.0 but cannot – in ASP.NET projects targeted to .NET 2.0 ?
I understand that this is C# 3.0 features, but don’t – why this possible to use in .NET 2.0 projects.
Probably because the ASP.Net stuff targeting the 2.0 framework assumes it will run in a mode where it may have to compile some code on the fly. Since it is running in 2.0 mode it will get the 2.0 compiler at that stage (thus anything relying on the 3.0 compiler will fail)
When targeting the 2.0 codebase from a ‘normal’ project the compilation is done then and there so relying on 3.0 compiler functionality is fine.