Is it possible to use the C# 4 compiler in an ASP.NET 3.5 Web Site?
I am working with an ASP.NET Web Site project targeting .NET framework version 3.5 and I am wondering if it is possible to use the C# compiler for C#4. At the moment I don't have the time to upgrade the whole site to .NET framework 4 but I want to be able to use for instance optional parameters. As far as I know, optional parameters is not a framework 4 feature.
It this is possible, what changes to web.config must be done? (I guess it is开发者_运维知识库 a configuration issue.)
Try adding the following to Web.config
<configuration>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v4.0"/>
</compiler>
</compilers>
</system.codedom>
</configuration>
精彩评论