Optional Argument code compiles in .NET 3.5. Why?

安稳与你 提交于 2019-12-05 08:46:15

Project + Properties, Build tab, scroll down, Advanced. You can change the Language Version to "C# 3.0" if you prefer to maintain source code compatibility.

But yes, you are using the C# 4.0 compiler in VS2010, regardless of the target .NET version you use. The output of the compiler, IL, hasn't changed in .NET 4.0. No, you can't use dynamic, it requires a .NET 4.0 only support assembly (Microsoft.CSharp.dll)

Anon.

Optional parameters are merely syntactic sugar - if you don't specify it at the call site, the compiler fills it the default value. There's no dependancy on the .NET framework itself to do anything.

See also Can you use optional parameters in code targeting .NET 3.5?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!