If I have Visual Studio 2008 and I target a .NET 2.0 application, can I still use Lambda Expressions? My understanding of Lambda Expressions is that its a feature built into the compiler, not the framework, so my conclusion would be that I could use Lambda in .NET 2.0 application. Can someone please tell me if this is so?
相关问题
- How to know full paths to DLL's from .csproj f
- Importing NuGet references through a local project
- the application was unable to start correctly 0xc0
- Visual Studio 2019 - error MSB8020: The build tool
- 'System.Threading.ThreadAbortException' in
相关文章
- vb.net 关于xps文件操作问题
- How to show location of errors, references to memb
- How to add external file to application files ( cl
- Why doesn't C11 support lambda functions
- How to track MongoDB requests from a console appli
- Visual Studio Hangs on Loading UI Library
- How to use Mercurial from Visual Studio 2010?
- Checking for DBNull throws a StrongTypingException
Yes this is completely supported. As long as you do not build an expression tree or otherwise reference System.Core, System.Xml.Linq, etc ... it is perfectly legal to use Lambda expressions in a down targetted 2.0 application. This is true of any other compiler feature introduced in VS2008 (VB9).
EDIT
Several answers incorrectly state that Lambda Expressions are a feature of the 3.5 or 3.0 feature. Lambda expressions are a compiler feature not a Framework one. They require no framework support in order to function and it's perfectly legal to use them in a application down targetted to 2.0.
The only place you would get into trouble is if you used a lambda as an expression tree. Expression Trees are both a compiler and framework feature and do require 3.5 to function correctly. But you have to work hard to enable this as we actively try to prevent it from happening.
It does not work. Using Linq requires the System.Linq to be part of the framework assembly, which .NET 2.0 does not have.
Yes you are correct. You can use lambda expressions in place of anonymous methods. The compiler will sort the rest out. Try this:
What you cannot do is to use any of the new functionality of .Net 3.5 (ie. Linq). Doing so requires adding references to System.Linq, System.Core,etc.., which are not present in .Net 2.0.