VB.NET Lambda表达式 [英] VB.NET Lambda Expressions

查看:387
本文介绍了VB.NET Lambda表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我具有Visual Studio 2008,并且我针对的是.NET 2.0应用程序,那么我仍然可以使用Lambda表达式吗?我对Lambda表达式的理解是,它是内置于编译器而不是框架的功能,因此我的结论是,我可以在.NET 2.0应用程序中使用Lambda.有人可以告诉我吗?

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?

推荐答案

是的,这是完全受支持的.只要您不构建表达式树或以其他方式引用System.Core,System.Xml.Linq等,在面向目标的2.0应用程序中使用Lambda表达式是完全合法的. VS2008(VB9)中引入的任何其他编译器功能都是如此.

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).

编辑

几个答案错误地指出Lambda表达式是3.5或3.0功能的功能. Lambda表达式是一种编译器功能,而不是Framework功能.它们不需要框架支持即可运行,并且在降级到2.0的应用程序中使用它们是完全合法的.

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.

您唯一遇到麻烦的地方是使用lambda作为表达式树.表达式树既是编译器功能,又是框架功能,确实需要3.5才能正常运行.但是您必须努力使它成为可能,因为我们正在积极尝试防止这种情况的发生.

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.

这篇关于VB.NET Lambda表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆