CSDN专家博客精华版

为人民服务!
  首页  :: 新随笔  :: 管理

C#3.0/LINQ的新下载

Posted on 2007-12-17 10:30  csdnexpert  阅读(112)  评论(0)    收藏  举报

原文: New drop of C# 3.0/LINQ

下载地址:http://www.microsoft.com/downloads/details.aspx?familyid=1e902c21-340c-4d13-9f04-70eb5e3dceea&displaylang=en

我喜欢它的这一特色:LambdaExpression.Compile

Expression<Func<int, int>> expr = a => a + 3;
Console.WriteLine(expr); // prints "a => Add(a, 3)"
Func<int, int> func = expr.Compile(); // LCG's an MSIL method from the expr
Console.WriteLine(func(4)); // prints "7"
这些代码等同于
(define expr '(lambda (a) (+ a 3)))
(display expr)
(define func (eval expr (scheme-report-environment 5)))
(display (func 4))


Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1438370