SlideShare uma empresa Scribd logo
1 de 51















    o
    o


    o
    o

    o



    o
var entry = new {                 Dim entry = New With { _
    Title = "Dear Diary",             .Title = "Dear Diary", _
    DateTime.Now                      DateTime.Now _
};                                }

Console.WriteLine("{0:d}: {1}",   Console.WriteLine("{0:d}: {1}", _
    entry.Now, entry.Title);          entry.Now, entry.Title)




var         Dim
                         static                Module
                                                 using Imports

Imports System.Runtime.CompilerServices

Module StringExtensions
    <Extension()> _
    Public Sub Print(ByVal aString As String)
        Console.WriteLine(aString)
    End Sub
End Module

Dim hello = "Hello from StringExtensions"
hello.Print()
                 this
static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
{
    foreach (T o in source)
        action(o);
}


delegate   void Action();
delegate   void Action<T>(T arg);
delegate   void Action<T1, T2>(T1 arg1, T2 arg2);
delegate   TResult Func<TResult>();
delegate   TResult Func<T, TResult>(T arg);
delegate   TResult Func<T1, T2, TResult>(T1 arg1, T2 arg2);

delegate string MyDelegate(int i);

static string MyMethod(int i) { … }
MyDelegate del1 = new MyDelegate(MyMethod);   //   C#   1.0
MyDelegate del2 = delegate(int i) { … };      //   C#   2.0
MyDelegate del3 = MyMethod;                   //   C#   2.0
MyDelegate del4 = (int i) => { … };           //   C#   3.0
Func<int, string> del5 = i => { … };          //   C#   3.0


Dim del4 As MyDelegate = Function(i As Integer) …



Expression<Func<int, int>> inc = (a => a + 1);

ParameterExpression CS$a;
Expression<Func<int, int>> inc =
  Expression.Lambda<Func<int, int>>(
    Expression.Add(
      CS$a = Expression.Parameter(typeof(int), "a"),
      Expression.Constant(1, typeof(int))),
    new ParameterExpression[] { CS$a });

var names = from s in Students
            where s.Age % 2 == 0
            orderby s.Name descending
            select s.Name;



IEnumerable<string> names =
    Students.Where(s => s.Age % 2 == 0)
            .OrderByDescending(s => s.Name)
            .Select(s => s.Name);

    o
    o


    o



    o

    o   

    o   
    o   

    o   

    o
    o   
    o   




    o   

    o   
    o   















    from x1 in e1
    join x2 in e2 on k1 equals k2
    …

    from * in ( e1 ) . Join(
      e2 , x1 => k1 , x2 => k2 , (x1 , x2) => new { x1 , x2 })
    …

    o   this
    o
    o
    o
    o

    o   EqualityComparer<TKey>.Default

    o                Equals()   GetHashcode()
    o

           IEqualityComparer<TKey>
    o
    o
           into
    o
    o   Func<TOuter, TInner, TResult> resultSelector
                   into
    o


    o
    o   Func<TOuter, IEnumerable<TInner>, TResult> resultSelector

    o       DefaultIfEmpty()
        from x1 in e1
        join x2 in e2 on k1 equals k2 into j
        from xj in j . DefaultIfEmpty()
        …
                       from
    o                                  IEnumerable<T>


from x1 in e1
from x2 in e2
…

from * in ( e1 ) . SelectMany(
    x1 => e2 , ( x1 , x2 ) => new { x1 , x2 } )
…
        *
    o


    o                  IEnumerable<T>

    o   yield return

    o
    o
    o
    o

    o
    o


    o
        •   foreach

    o


    o


    o

    o
    o                  IEnumerable<>

    o
    o   EnumerableRowCollection<DataRow>
            AsEnumerable(this DataTable source)
    o   EnumerableRowCollectionExtensions

    o                  Cast<T>()     OfType<T>()
    o                                foreach
        from MyType obj in MyArrayList
        …


    o                   IQueryable<T>


public interface IQueryable   : IEnumerable
{
    Type ElementType { get;   }
    Expression Expression {   get; }
    IQueryProvider Provider   { get; }
}

public interface IQueryable<T> :
    IEnumerable<T>, IQueryable, IEnumerable
{ }



public interface IQueryProvider
{
    IQueryable CreateQuery(Expression expression);
    IQueryable<TElement>
        CreateQuery<TElement>(Expression expression);

    object Execute(Expression expression);
    TResult Execute<TResult>(Expression expression);
}
public static TSource First<TSource>(
                      this IQueryable<TSource> source)
{
  return source.Provider.Execute<TSource>(
    Expression.Call(null,
      ((MethodInfo) MethodBase.GetCurrentMethod())
        .MakeGenericMethod(new Type[] { typeof(TSource) }),
      new Expression[] { source.Expression }
    )
  );
}
   IEnumerable   IQueryable


    o
    o


    o
    o


    o





    o
    o
    o

Mais conteúdo relacionado

Mais procurados

Data structure
Data structureData structure
Data structureMarkustec
 
The Ring programming language version 1.2 book - Part 30 of 84
The Ring programming language version 1.2 book - Part 30 of 84The Ring programming language version 1.2 book - Part 30 of 84
The Ring programming language version 1.2 book - Part 30 of 84Mahmoud Samir Fayed
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentationMartin McBride
 
Closure, Higher-order function in Swift
Closure, Higher-order function in SwiftClosure, Higher-order function in Swift
Closure, Higher-order function in SwiftSeongGyu Jo
 
jq: JSON - Like a Boss
jq: JSON - Like a Bossjq: JSON - Like a Boss
jq: JSON - Like a BossBob Tiernay
 
20180310 functional programming
20180310 functional programming20180310 functional programming
20180310 functional programmingChiwon Song
 
Introduction to JQ
Introduction to JQIntroduction to JQ
Introduction to JQKnoldus Inc.
 
The Ring programming language version 1.9 book - Part 34 of 210
The Ring programming language version 1.9 book - Part 34 of 210The Ring programming language version 1.9 book - Part 34 of 210
The Ring programming language version 1.9 book - Part 34 of 210Mahmoud Samir Fayed
 
Java Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesJava Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesOXUS 20
 
Java Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesJava Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesAbdul Rahman Sherzad
 
Perceptron
PerceptronPerceptron
Perceptronunhas
 
Lecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of TwenteLecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of TwenteDirkjan Bussink
 
20180721 code defragment
20180721 code defragment20180721 code defragment
20180721 code defragmentChiwon Song
 
The Ring programming language version 1.10 book - Part 48 of 212
The Ring programming language version 1.10 book - Part 48 of 212The Ring programming language version 1.10 book - Part 48 of 212
The Ring programming language version 1.10 book - Part 48 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.2 book - Part 26 of 181The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.2 book - Part 26 of 181Mahmoud Samir Fayed
 
20181020 advanced higher-order function
20181020 advanced higher-order function20181020 advanced higher-order function
20181020 advanced higher-order functionChiwon Song
 

Mais procurados (19)

Data structure
Data structureData structure
Data structure
 
The Ring programming language version 1.2 book - Part 30 of 84
The Ring programming language version 1.2 book - Part 30 of 84The Ring programming language version 1.2 book - Part 30 of 84
The Ring programming language version 1.2 book - Part 30 of 84
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentation
 
Closure, Higher-order function in Swift
Closure, Higher-order function in SwiftClosure, Higher-order function in Swift
Closure, Higher-order function in Swift
 
jq: JSON - Like a Boss
jq: JSON - Like a Bossjq: JSON - Like a Boss
jq: JSON - Like a Boss
 
20180310 functional programming
20180310 functional programming20180310 functional programming
20180310 functional programming
 
Introduction to JQ
Introduction to JQIntroduction to JQ
Introduction to JQ
 
The Ring programming language version 1.9 book - Part 34 of 210
The Ring programming language version 1.9 book - Part 34 of 210The Ring programming language version 1.9 book - Part 34 of 210
The Ring programming language version 1.9 book - Part 34 of 210
 
Java Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesJava Unicode with Cool GUI Examples
Java Unicode with Cool GUI Examples
 
Java Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesJava Unicode with Live GUI Examples
Java Unicode with Live GUI Examples
 
C++ L06-Pointers
C++ L06-PointersC++ L06-Pointers
C++ L06-Pointers
 
Perceptron
PerceptronPerceptron
Perceptron
 
C++ L04-Array+String
C++ L04-Array+StringC++ L04-Array+String
C++ L04-Array+String
 
Clojure functions examples
Clojure functions examplesClojure functions examples
Clojure functions examples
 
Lecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of TwenteLecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of Twente
 
20180721 code defragment
20180721 code defragment20180721 code defragment
20180721 code defragment
 
The Ring programming language version 1.10 book - Part 48 of 212
The Ring programming language version 1.10 book - Part 48 of 212The Ring programming language version 1.10 book - Part 48 of 212
The Ring programming language version 1.10 book - Part 48 of 212
 
The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.2 book - Part 26 of 181The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.2 book - Part 26 of 181
 
20181020 advanced higher-order function
20181020 advanced higher-order function20181020 advanced higher-order function
20181020 advanced higher-order function
 

Destaque

TechTalk #67 : Introduction to Ruby and Sinatra
TechTalk #67 : Introduction to Ruby and SinatraTechTalk #67 : Introduction to Ruby and Sinatra
TechTalk #67 : Introduction to Ruby and Sinatrabincangteknologi
 
Pry open qiscus
Pry open qiscusPry open qiscus
Pry open qiscusQiscus
 
Qiscus TechTalk - Real-time Website with Node.js (socket.io)
Qiscus TechTalk - Real-time Website with Node.js (socket.io)Qiscus TechTalk - Real-time Website with Node.js (socket.io)
Qiscus TechTalk - Real-time Website with Node.js (socket.io)Qiscus
 
Qiscus the enterprise app
Qiscus the enterprise appQiscus the enterprise app
Qiscus the enterprise appdeltapurna
 
Growth Hacking with Jon Eilerman
Growth Hacking with Jon EilermanGrowth Hacking with Jon Eilerman
Growth Hacking with Jon EilermanQiscus
 
Qiscus enterprice for Hotels
Qiscus enterprice for HotelsQiscus enterprice for Hotels
Qiscus enterprice for Hotelsbincangteknologi
 
Redis for high performance application - Techtalk JDV 23-04-2014
Redis for high performance application - Techtalk JDV 23-04-2014Redis for high performance application - Techtalk JDV 23-04-2014
Redis for high performance application - Techtalk JDV 23-04-2014rifqi alfian
 
Ddd part 2 modelling qiscus
Ddd part 2   modelling qiscusDdd part 2   modelling qiscus
Ddd part 2 modelling qiscusbincangteknologi
 

Destaque (8)

TechTalk #67 : Introduction to Ruby and Sinatra
TechTalk #67 : Introduction to Ruby and SinatraTechTalk #67 : Introduction to Ruby and Sinatra
TechTalk #67 : Introduction to Ruby and Sinatra
 
Pry open qiscus
Pry open qiscusPry open qiscus
Pry open qiscus
 
Qiscus TechTalk - Real-time Website with Node.js (socket.io)
Qiscus TechTalk - Real-time Website with Node.js (socket.io)Qiscus TechTalk - Real-time Website with Node.js (socket.io)
Qiscus TechTalk - Real-time Website with Node.js (socket.io)
 
Qiscus the enterprise app
Qiscus the enterprise appQiscus the enterprise app
Qiscus the enterprise app
 
Growth Hacking with Jon Eilerman
Growth Hacking with Jon EilermanGrowth Hacking with Jon Eilerman
Growth Hacking with Jon Eilerman
 
Qiscus enterprice for Hotels
Qiscus enterprice for HotelsQiscus enterprice for Hotels
Qiscus enterprice for Hotels
 
Redis for high performance application - Techtalk JDV 23-04-2014
Redis for high performance application - Techtalk JDV 23-04-2014Redis for high performance application - Techtalk JDV 23-04-2014
Redis for high performance application - Techtalk JDV 23-04-2014
 
Ddd part 2 modelling qiscus
Ddd part 2   modelling qiscusDdd part 2   modelling qiscus
Ddd part 2 modelling qiscus
 

Semelhante a Kdahlby 200908 Stldodn Linqinternals 090903222505 Phpapp01

Monadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query ExpressionsMonadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query ExpressionsChris Eargle
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Codemotion
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with GroovyArturo Herrero
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfshreeaadithyaacellso
 
c++ Lecture 4
c++ Lecture 4c++ Lecture 4
c++ Lecture 4sajidpk92
 
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS - SARASWATHI RAMALINGAM
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS  - SARASWATHI RAMALINGAMPROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS  - SARASWATHI RAMALINGAM
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS - SARASWATHI RAMALINGAMSaraswathiRamalingam
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parserkamaelian
 
The underestimated power of KeyPaths
The underestimated power of KeyPathsThe underestimated power of KeyPaths
The underestimated power of KeyPathsVincent Pradeilles
 
Hello, I need some assistance in writing a java program THAT MUST US.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdfHello, I need some assistance in writing a java program THAT MUST US.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdfFashionColZone
 
how to reuse code
how to reuse codehow to reuse code
how to reuse codejleed1
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallyRound PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallySean Cribbs
 
Crafting Custom Interfaces with Sub::Exporter
Crafting Custom Interfaces with Sub::ExporterCrafting Custom Interfaces with Sub::Exporter
Crafting Custom Interfaces with Sub::ExporterRicardo Signes
 
Linq Sanjay Vyas
Linq   Sanjay VyasLinq   Sanjay Vyas
Linq Sanjay Vyasrsnarayanan
 

Semelhante a Kdahlby 200908 Stldodn Linqinternals 090903222505 Phpapp01 (20)

C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
Monadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query ExpressionsMonadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query Expressions
 
C sharp 8
C sharp 8C sharp 8
C sharp 8
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with Groovy
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdf
 
c++ Lecture 4
c++ Lecture 4c++ Lecture 4
c++ Lecture 4
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
lesson 2.pptx
lesson 2.pptxlesson 2.pptx
lesson 2.pptx
 
C++ practical
C++ practicalC++ practical
C++ practical
 
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS - SARASWATHI RAMALINGAM
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS  - SARASWATHI RAMALINGAMPROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS  - SARASWATHI RAMALINGAM
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS - SARASWATHI RAMALINGAM
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parser
 
The underestimated power of KeyPaths
The underestimated power of KeyPathsThe underestimated power of KeyPaths
The underestimated power of KeyPaths
 
Hello, I need some assistance in writing a java program THAT MUST US.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdfHello, I need some assistance in writing a java program THAT MUST US.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdf
 
DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
 
how to reuse code
how to reuse codehow to reuse code
how to reuse code
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallyRound PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing Functionally
 
Crafting Custom Interfaces with Sub::Exporter
Crafting Custom Interfaces with Sub::ExporterCrafting Custom Interfaces with Sub::Exporter
Crafting Custom Interfaces with Sub::Exporter
 
Linq Sanjay Vyas
Linq   Sanjay VyasLinq   Sanjay Vyas
Linq Sanjay Vyas
 

Mais de google

Rolling Linq Wcf Silverlight Old4830
Rolling Linq Wcf Silverlight Old4830Rolling Linq Wcf Silverlight Old4830
Rolling Linq Wcf Silverlight Old4830google
 
Linq To Sql 1221970293242272 9
Linq To Sql 1221970293242272 9Linq To Sql 1221970293242272 9
Linq To Sql 1221970293242272 9google
 
Linq 1207579553462901 8
Linq 1207579553462901 8Linq 1207579553462901 8
Linq 1207579553462901 8google
 
Linq E Ef 1207668728621762 9
Linq E Ef 1207668728621762 9Linq E Ef 1207668728621762 9
Linq E Ef 1207668728621762 9google
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9google
 
Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01google
 
L2s 090701234157 Phpapp02
L2s 090701234157 Phpapp02L2s 090701234157 Phpapp02
L2s 090701234157 Phpapp02google
 
Introduccion A Linq 1205779028184546 5
Introduccion A Linq 1205779028184546 5Introduccion A Linq 1205779028184546 5
Introduccion A Linq 1205779028184546 5google
 
Seminarv2 0 090609060123 Phpapp01
Seminarv2 0 090609060123 Phpapp01Seminarv2 0 090609060123 Phpapp01
Seminarv2 0 090609060123 Phpapp01google
 
Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01google
 
Linq 090611123548 Phpapp02
Linq 090611123548 Phpapp02Linq 090611123548 Phpapp02
Linq 090611123548 Phpapp02google
 

Mais de google (12)

Rolling Linq Wcf Silverlight Old4830
Rolling Linq Wcf Silverlight Old4830Rolling Linq Wcf Silverlight Old4830
Rolling Linq Wcf Silverlight Old4830
 
Linq To Sql 1221970293242272 9
Linq To Sql 1221970293242272 9Linq To Sql 1221970293242272 9
Linq To Sql 1221970293242272 9
 
Linq 1207579553462901 8
Linq 1207579553462901 8Linq 1207579553462901 8
Linq 1207579553462901 8
 
Linq E Ef 1207668728621762 9
Linq E Ef 1207668728621762 9Linq E Ef 1207668728621762 9
Linq E Ef 1207668728621762 9
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
 
Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01
 
L2s 090701234157 Phpapp02
L2s 090701234157 Phpapp02L2s 090701234157 Phpapp02
L2s 090701234157 Phpapp02
 
Introduccion A Linq 1205779028184546 5
Introduccion A Linq 1205779028184546 5Introduccion A Linq 1205779028184546 5
Introduccion A Linq 1205779028184546 5
 
Seminarv2 0 090609060123 Phpapp01
Seminarv2 0 090609060123 Phpapp01Seminarv2 0 090609060123 Phpapp01
Seminarv2 0 090609060123 Phpapp01
 
Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01
 
Linq 090611123548 Phpapp02
Linq 090611123548 Phpapp02Linq 090611123548 Phpapp02
Linq 090611123548 Phpapp02
 
Linq
LinqLinq
Linq
 

Kdahlby 200908 Stldodn Linqinternals 090903222505 Phpapp01

  • 1.
  • 4.   o o  o o
  • 5. o   o
  • 6. var entry = new { Dim entry = New With { _ Title = "Dear Diary", .Title = "Dear Diary", _ DateTime.Now DateTime.Now _ }; } Console.WriteLine("{0:d}: {1}", Console.WriteLine("{0:d}: {1}", _ entry.Now, entry.Title); entry.Now, entry.Title) var Dim
  • 7. static Module  using Imports  Imports System.Runtime.CompilerServices Module StringExtensions <Extension()> _ Public Sub Print(ByVal aString As String) Console.WriteLine(aString) End Sub End Module Dim hello = "Hello from StringExtensions" hello.Print()
  • 8. this static void ForEach<T>(this IEnumerable<T> source, Action<T> action) { foreach (T o in source) action(o); }  delegate void Action(); delegate void Action<T>(T arg); delegate void Action<T1, T2>(T1 arg1, T2 arg2); delegate TResult Func<TResult>(); delegate TResult Func<T, TResult>(T arg); delegate TResult Func<T1, T2, TResult>(T1 arg1, T2 arg2);
  • 9.  delegate string MyDelegate(int i); static string MyMethod(int i) { … } MyDelegate del1 = new MyDelegate(MyMethod); // C# 1.0 MyDelegate del2 = delegate(int i) { … }; // C# 2.0 MyDelegate del3 = MyMethod; // C# 2.0 MyDelegate del4 = (int i) => { … }; // C# 3.0 Func<int, string> del5 = i => { … }; // C# 3.0  Dim del4 As MyDelegate = Function(i As Integer) …
  • 10.    Expression<Func<int, int>> inc = (a => a + 1);  ParameterExpression CS$a; Expression<Func<int, int>> inc = Expression.Lambda<Func<int, int>>( Expression.Add( CS$a = Expression.Parameter(typeof(int), "a"), Expression.Constant(1, typeof(int))), new ParameterExpression[] { CS$a });
  • 11.  var names = from s in Students where s.Age % 2 == 0 orderby s.Name descending select s.Name;  IEnumerable<string> names = Students.Where(s => s.Age % 2 == 0) .OrderByDescending(s => s.Name) .Select(s => s.Name);
  • 12. o o  o  o
  • 13. o   o  o   o   o o  o   o   o  o 
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34. from x1 in e1 join x2 in e2 on k1 equals k2 …  from * in ( e1 ) . Join( e2 , x1 => k1 , x2 => k2 , (x1 , x2) => new { x1 , x2 }) …  o this o o o o
  • 35. o EqualityComparer<TKey>.Default  o Equals() GetHashcode() o  IEqualityComparer<TKey> o o
  • 36.
  • 37. into o o Func<TOuter, TInner, TResult> resultSelector  into o o o Func<TOuter, IEnumerable<TInner>, TResult> resultSelector  o DefaultIfEmpty() from x1 in e1 join x2 in e2 on k1 equals k2 into j from xj in j . DefaultIfEmpty() …
  • 38. from o IEnumerable<T>  from x1 in e1 from x2 in e2 …  from * in ( e1 ) . SelectMany( x1 => e2 , ( x1 , x2 ) => new { x1 , x2 } ) …  * o
  • 39.   o IEnumerable<T>  o yield return  o o o o
  • 40. o o  o • foreach o  o  o
  • 41.
  • 42.
  • 43.
  • 44. o o IEnumerable<>  o o EnumerableRowCollection<DataRow> AsEnumerable(this DataTable source) o EnumerableRowCollectionExtensions  o Cast<T>() OfType<T>() o foreach from MyType obj in MyArrayList …
  • 45.
  • 46.   o IQueryable<T> public interface IQueryable : IEnumerable { Type ElementType { get; } Expression Expression { get; } IQueryProvider Provider { get; } } public interface IQueryable<T> : IEnumerable<T>, IQueryable, IEnumerable { }
  • 47.  public interface IQueryProvider { IQueryable CreateQuery(Expression expression); IQueryable<TElement> CreateQuery<TElement>(Expression expression); object Execute(Expression expression); TResult Execute<TResult>(Expression expression); }
  • 48. public static TSource First<TSource>( this IQueryable<TSource> source) { return source.Provider.Execute<TSource>( Expression.Call(null, ((MethodInfo) MethodBase.GetCurrentMethod()) .MakeGenericMethod(new Type[] { typeof(TSource) }), new Expression[] { source.Expression } ) ); }
  • 49.
  • 50. IEnumerable IQueryable   o o  o o
  • 51.   o  o o o