Microsoft MVP                Chander Dhall
Delegates – WHAT?A type that defines a method signature
Delegates – WHAT?Function pointers but type safe
Delegates – WHAT?Allow methods to be passed as         parameters
Delegates – WHAT?Can be chained together
Delegates – WHY?  Decoupling Code
Delegates – WHY?  Methods as Parameters
Delegates – WHY?Muli-casting NOT Multi-tasking
Delegates – WHY?Callbacks and Event Handlers
Delegates – WHY?         LINQ
How to implement right?  I can find all this online      Where to implement?Why do I attend your talk?      How to implem...
Demo
Expression TreesReference executable code
Expression Trees        Form of Data structureReferences executable code
Expression Trees                 Expression Lambda            Binary         ConstantExpression       Expression     Expre...
Linq To ObjectsC# code with                 IL using delegates   Results  lambda
Linq To ObjectsC# code with         IL using                                    Dynamic Sql  lambda         expression tre...
Expression Trees Immutable so cacheable
Expression TreesComposable to complex behavior
Expression TreesCompiled to delegate JITed to native code
Upcoming SlideShare
Loading in …5
×

From delegates, to lamdas and expression trees your guide to elegant code in c#.net 4.0

1,154 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

From delegates, to lamdas and expression trees your guide to elegant code in c#.net 4.0

  1. 1. Microsoft MVP Chander Dhall
  2. 2. Delegates – WHAT?A type that defines a method signature
  3. 3. Delegates – WHAT?Function pointers but type safe
  4. 4. Delegates – WHAT?Allow methods to be passed as parameters
  5. 5. Delegates – WHAT?Can be chained together
  6. 6. Delegates – WHY? Decoupling Code
  7. 7. Delegates – WHY? Methods as Parameters
  8. 8. Delegates – WHY?Muli-casting NOT Multi-tasking
  9. 9. Delegates – WHY?Callbacks and Event Handlers
  10. 10. Delegates – WHY? LINQ
  11. 11. How to implement right? I can find all this online Where to implement?Why do I attend your talk?  How to implement?
  12. 12. Demo
  13. 13. Expression TreesReference executable code
  14. 14. Expression Trees Form of Data structureReferences executable code
  15. 15. Expression Trees Expression Lambda Binary ConstantExpression Expression Expression etc Expression<Tdelegate>
  16. 16. Linq To ObjectsC# code with IL using delegates Results lambda
  17. 17. Linq To ObjectsC# code with IL using Dynamic Sql lambda expression trees Results
  18. 18. Expression Trees Immutable so cacheable
  19. 19. Expression TreesComposable to complex behavior
  20. 20. Expression TreesCompiled to delegate JITed to native code

×