473,240 Members | 1,632 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,240 software developers and data experts.

Lambda-Expressions

hi @all,

I stumbled upon this one:

MethodInvoker listMethodInvoker =
() =list = Broker.RetrieveList<T>();

This works fine for me under VS2008 and target .Net 2.0. The question
is: Why?

All sources in the net state that lambda expressions where introduced
with C# 3.0.

(VS2008 == C# 3.0) ?
mfG
--stefan <--
Sep 2 '08 #1
6 2285
VS2008 uses C# 3 even when targetting .NET 3.0 or .NET 2.0; the
language and the runtime are separate things. Equally, you can use
anonymous types, auto-implemented properties, etc with .NET 2.0 and
VS2008. You can even use extension methods if you declare a missing
attribute - or LINQ-to-Objects is fairly easy to reproduce (see:
LINQBridge).

Marc
Sep 2 '08 #2
One other clarification: lambda expressions can be compiled either to
a delegate or to an Expression. The delegate form (which you are
using) can be used with .NET 2.0 etc, as it is the same as an
anonymous method. The Expression form uses types that are only
available in .NET 3.5 (and would be painful to back-port to .NET 2.0,
so I don't anticipate a LINQBridge equivalent for Expression).
Finally, there is also a "lambda statament" - this is always compiled
to a delegate instance, so can be used with .NET 2.0 etc.

Marc
Sep 2 '08 #3

"Stefan Hoffmann" <st*************@explido.dewrote in message
news:eJ**************@TK2MSFTNGP06.phx.gbl...
hi @all,

I stumbled upon this one:

MethodInvoker listMethodInvoker =
() =list = Broker.RetrieveList<T>();

This works fine for me under VS2008 and target .Net 2.0. The question is:
Why?

All sources in the net state that lambda expressions where introduced with
C# 3.0.

(VS2008 == C# 3.0) ?
VS2008 always compiles C# as 3.0, even if you target .NET 2.0. "Target
framework" only defines the set of assemblies your program will depend on,
not the language features. So you can use all the new C# 3.0 language
features, and still run on .NET 2.0. Some of the new features - such as
LINQ - require some library stuff, but so long as you have it for 2.0, you
can use them there too. For example, to use LINQ on 2.0, try LINQBridge.
Sep 2 '08 #4
hi Marc,

Marc Gravell wrote:
VS2008 uses C# 3 even when targetting .NET 3.0 or .NET 2.0; the
language and the runtime are separate things. Equally, you can use
anonymous types, auto-implemented properties, etc with .NET 2.0 and
VS2008.
Thanks, that was my finding, too. But I wasn't aware of it.

mfG
--stefan <--
Sep 2 '08 #5
Stefan Hoffmann expressed precisely :
hi @all,

I stumbled upon this one:

MethodInvoker listMethodInvoker =
() =list = Broker.RetrieveList<T>();

This works fine for me under VS2008 and target .Net 2.0. The question is:
Why?

All sources in the net state that lambda expressions where introduced with C#
3.0.

(VS2008 == C# 3.0) ?
mfG
--stefan <--

VS2008 does indeed always work with the C# 3.0 compiler and you can
choose the *framework* version to compile against (2.0, 3.0, 3.5).
To make it even more complicated, everything uses CLR version 2.

Hans Kesting
Sep 2 '08 #6
On Sep 2, 2:43*pm, Stefan Hoffmann <stefan.hoffm...@explido.dewrote:
Marc Gravell wrote:
VS2008 uses C# 3 even when targetting .NET 3.0 or .NET 2.0; the
language and the runtime are separate things. Equally, you can use
anonymous types, auto-implemented properties, etc with .NET 2.0 and
VS2008.

Thanks, that was my finding, too. But I wasn't aware of it.
See http://csharpindepth.com/Articles/Ch.../Versions.aspx for more
on this.

Jon
Sep 2 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
by: Oliver Fromme | last post by:
Hi, I'm trying to write a Python function that parses an expression and builds a function tree from it (recursively). During parsing, lambda functions for the the terms and sub-expressions...
63
by: Stephen Thorne | last post by:
Hi guys, I'm a little worried about the expected disappearance of lambda in python3000. I've had my brain badly broken by functional programming in the past, and I would hate to see things...
7
by: Paddy McCarthy | last post by:
Hi, I am trying to use eval as little as possible but solve this problem. #If given:two or more lambda equations x=lambda : A < B y=lambda : C+6 >= 7 .... How do I create another lambda...
17
by: mehmetmutigozel | last post by:
I was thinking about something like the following; >>> a= Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 't' is not defined >>> or
181
by: Tom Anderson | last post by:
Comrades, During our current discussion of the fate of functional constructs in python, someone brought up Guido's bull on the matter: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 ...
25
by: Russell | last post by:
I want my code to be Python 3000 compliant, and hear that lambda is being eliminated. The problem is that I want to partially bind an existing function with a value "foo" that isn't known until...
4
by: Xah Lee | last post by:
A Lambda Logo Tour (and why LISP languages using λ as logo should not be looked upon kindly) Xah Lee, 2002-02 Dear lispers, The lambda character λ, always struck a awe in me, as with...
8
by: rubbishemail | last post by:
Hello, I need your help understanding lambda (and doing it a better way without). f = lambda x : x*x # this is a list of functions
21
by: globalrev | last post by:
i have a rough understanding of lambda but so far only have found use for it once(in tkinter when passing lambda as an argument i could circumvent some tricky stuff). what is the point of the...
1
by: Tim H | last post by:
Compiling with g++ 4: This line: if_then_else_return(_1 == 0, 64, _1) When called with a bignum class as an argument yields: /usr/include/boost/lambda/if.hpp: In member function 'RET...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.