Introduction to C# 3.0


Published on


Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Introduction to C# 3.0

  1. 1. Overview of C# 3.0<br />Presentation created by EriawanKusumawardhono, for RX Communica<br />
  2. 2. C# 3.0 is?<br />A part of .NET programming languages from Microsoft<br />It is released with Visual Studio 2008 and .NET 3.5<br />
  3. 3. Historical perspective of C# 3.0<br />A quick tour of historical view<br />
  4. 4. Beginning of C#<br />C# was a first managed language to compete with Java<br />Microsoft was lost in court because of J++ implementation<br />C# 1.0 was designed and developed in 1999<br />C# 1.0 has basic OOP of inheritance, polymorphism<br />Property mechanism is the same concept as VB 4.0+<br />
  5. 5. C# is?<br />Statically typed language<br />Early bound<br />Based on CLR and CTS of .NET<br />Also part of “curly braces” languages such as C, C++, Objective C, Java<br />Imperative language as part of OOP<br />
  6. 6. Managed language is simply virtualization<br />Just like Java runs in its VM<br />Virtualization promotes cleaner environment, optimization, garbage collection, thread optimization within one “virtual” platform<br />A light lose coupling between OS and application written in managed environment or virtualization<br />Reduced OS version dependency and functionality<br />
  7. 7. So why?<br />It is simply, raising an abstraction, not adding abstraction<br />Focusing more on what you want to be done, not how<br />
  8. 8. The sample of adding abstraction: batch command<br />
  9. 9. Raising level of abstraction<br />
  10. 10. Conceptual difference of abstraction<br />Raising abstraction<br />Intended to be more declarative<br />Does not hide the detail of underlying platform<br />Still can access the OS API using P/Invoke in .NET and JNI in Java<br />Adding abstraction<br />Not intended to be more declarative<br />Often creating more new conceptual topics<br />Often hide the detail of the underlying platform<br />
  11. 11. What comes with C# 2.0<br />Adding generics on type and method declaration<br />Generic type inference on methods and method parameters<br />Reflection granularity<br />Nullable types<br />Iterator of “yield”<br />Anonymous delegate<br />
  12. 12. Current release of C#: 3.0<br />Present state of C# (2009)<br />
  13. 13. Continuous design from previous releases<br />New features are based on previous releases<br />Maintaining runtime compatibility and based on CLR of .NET 2.0<br />
  14. 14. C# 3.0 theme<br />LINQ<br />Functional programming in style<br />
  15. 15. LINQ is build on<br />Query comprehension<br />Extension method<br />Lambda expression<br />Expression tree<br />Property initializer<br />Anonymous type initializer<br />Local variable type inference<br />
  16. 16. Quick feature look<br />var x = from c in db.customer<br /> where c.City ==“London” <br /> select c.Name, c.City<br />Local type infer<br />Query comprehension<br />Lambda expression<br />var x = db.Customer<br /> .Where(c =&gt; c.City == “London”)<br /> .Select(c=&gt; new {c.Name,c.City}<br />Extension method<br />Anonymous object/type initializer<br />
  17. 17. Query comprehension<br />Adapting SQL query of SELECT<br />Not a real keyword in C#, it is a pseudo keyword<br />SELECT, WHERE, ORDER BY, GROUP BY is then translated into calls to extension methods<br />
  18. 18. Lambda Expression overview<br />It is simply an anonymous delegate but with the functional math syntax<br />Taken from ideas in Lambda calculus<br />
  19. 19. Extension methods<br />Adding static method to a class or interfaces without deriving it<br />Use it wisely<br />Can be a bad smell in coding practice<br />
  20. 20. Next is: C# 4.0<br />Main theme: support for dynamic type<br />
  21. 21. Overview of C# 4.0<br />Dynamic type<br />Co and Contra variance<br />Optional and named parameters<br />No PIA<br />
  22. 22. Beyond C# 4.0<br />Compiler as a service<br />True meta programming<br />Method execution into multi core (parallel)<br />Function purity<br />
  23. 23. End<br />