Your SlideShare is downloading. ×
0
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Cs30 New
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Cs30 New

751

Published on

This is the presentation to explain what's new in C# 3.0 programming language

This is the presentation to explain what's new in C# 3.0 programming language

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
751
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
42
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. C# 3.0 What’s new by Chakravarthy http://msmvps.com/blogs/chakravarthy [email_address] Project Lead
  • 2. Agenda
    • What’s new in Orcas
    • C# 3.0
      • Implicit Variables
      • Auto implemented properties
      • Object & Collection Initializers
      • Extension Methods
      • Anonymous Types
      • Lambda Expressions
      • Generic Delegates
      • Expression Trees
    Are we missing any thing here ?????
  • 3. Pre-Requisites
    • Some Programming Exp
    • C
    • C ++
    • .NET Basics
    • Apart of all ..
    Imagination is more important than knowledge .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
  • 4. Ur acquaintance with C#
    • Using it more than 2 Yrs
    • Started Recently
    • Am new to C#
    • What C# is ..?
  • 5. Orcas What is ? Specialisation doesn’t mean doing extraordinary things But doing ordinary things, extraordinarily well..
  • 6. Visual Studio Code Name – Orcas
    • Web
      • Multi version apps
      • CSS Design tools
      • Intellisense for ECMA Script
      • AJAX Library
    • Applications Templates
      • WPF
      • WCF
      • WF
    • Data Integration
      • EDM – Entity Data Manager (ADO.NET vNext)
      • Multi-tier Dataset
      • Reporting Project templates
  • 7. demo Visual Studio Code name Orcas
    • Ctrl+Tab
    • MultiVersion
    • ECMA Intellisupport
    • DataIntegration(EDM)
    • AJAX Support
    • CSS
  • 8. C# 3.0 Features If we fail to plan, we are planning to fail
  • 9. Agenda
    • What’s new in Orcas
    • C# 3.0
      • Implicit Variables
      • Auto implemented properties
      • Object & Collection Initializers
      • Extension Methods
      • Anonymous Types / Tuples
      • Lambda Expressions
      • Generic Delegates (Func)
      • Expression Methods
      • Partial Methods
  • 10. Implicitly typed local variables
    • Declared as ‘var’ – compiler will determine type while initialization
    • Can only be used when declared and initialized in same statement
    • Can’t be null
    • Can’t be class members
    • Used to store anonymous types as in LINQ based programming
    • Don’t confuse with “var” at JavaScript or VB, which actually allows you to assign any type to a variable in your code
    • Multiple declarations should evaluate at Compile time
      • var bVal = true;
      • var strVal = “MATUG”;
      • Var intNum = 9;
      • var obj = new { UGName = “Automated Test”, url = “http://matug.net”, alturl =“http://groups.msn.com/matug/”}
  • 11. Implicitly typed arrays
    • Declared as ‘var’ – compiler will determine type while initialization
    • Collection type of elements is determined by compiler
      • var fstArry = new[] {3,6,11,78,93};  Int32
      • var secArry = new[] {3,6,11.48,78,93};  Double
      • var thrArry = new[] {“Microsoft”, “MAQ”};  String
      • var secArry = new[] {3,6,11.48,”78”,93};  Won’t compile due to irregularity in the elements
  • 12. demo Implicit Variables
    • Variables
    • Multiple Declaration
    • Typed Arrays
    • Arrays Mismatch
  • 13. Agenda
    • What’s new in Orcas
    • C# 3.0
      • Implicit Variables
      • Auto implemented properties
      • Object & Collection Initializers
      • Extension Methods
      • Anonymous Types / Tuples
      • Lambda Expressions
      • Generic Delegates (Func)
      • Expression Methods
      • Partial Methods
  • 14. Auto implemented properties
    • Compiler will create the private variables
    • Single line public property accessor
    • Simple object persistence mechanism
    Old Style private string strVar; public string EmployeeName { get{return strVar;} set{strVar = value;} } C# 3.0 public string EmployeeName { get; set; } Would you like to know what happens behind the screen ?
  • 15. Auto implemented properties Assembler will give you the code similar to the below namespace SampleLib { public class YesClass { // Fields [ CompilerGenerated ] private string <>k__AutomaticallyGeneratedPropertyField0 ; // Methods public YesClass (); public void DoNothing (); // Properties public string Reply { [ CompilerGenerated ] get; [ CompilerGenerated ] set; } } } How do you know this ? … Use any Reflector ..
  • 16. demo Property
    • Property
    • Reflector
  • 17. Agenda
    • What’s new in Orcas
    • C# 3.0
      • Implicit Variables
      • Auto implemented properties
      • Object & Collection Initializers
      • Extension Methods
      • Anonymous Types / Tuples
      • Lambda Expressions
      • Generic Delegates (Func)
      • Expression Methods
      • Partial Methods
  • 18. Object & Collection Initializers
    • Declaration and initialization at one step
    • Ease of construction and initialization process
    • Sequence of members are separated by ‘,’
    • Should be an accessible field assigned with = operator
  • 19. demo Object & Collections
    • Object from a class
    • Collections from a List <>
  • 20. Agenda
    • What’s new in Orcas
    • C# 3.0
      • Implicit Variables
      • Auto implemented properties
      • Object & Collection Initializers
      • Extension Methods
      • Anonymous Types / Tuples
      • Lambda Expressions
      • Generic Delegates (Func)
      • Expression Methods
      • Partial Methods
  • 21. Extension Methods
    • Static Methods
    • Invoked with instance method syntax
    • Declared by “this” keyword as modifier
    • Declared in “static” classes only
    • Extension members of other kinds, such as properties, events, and operators, are being considered but are currently not supported.
  • 22. demo Extension Methods
    • Reverse the given string
  • 23. Agenda
    • What’s new in Orcas
    • C# 3.0
      • Implicit Variables
      • Auto implemented properties
      • Object & Collection Initializers
      • Extension Methods
      • Anonymous Types / Tuples
      • Lambda Expressions
      • Generic Delegates (Func)
      • Expression Methods
      • Partial Methods
  • 24. Anonymous Types
    • No class code declaration
    • Direct initialization
    • Type is omitted at syntax
    • Not only the variables but objects can also be anonymous
    Old Style public class Book { … } Book bkObj = new Book(); C# 3.0 Style var bkObj = new { Title = “Harry Potter 7”, PubYr = 2007}
  • 25. Agenda
    • What’s new in Orcas
    • C# 3.0
      • Implicit Variables
      • Auto implemented properties
      • Object & Collection Initializers
      • Extension Methods
      • Anonymous Types / Tuples
      • Lambda Expressions
      • Generic Delegates (Func)
      • Expression Methods
      • Partial Methods
    Did I miss something???
  • 26. λ Lambda Expressions
    • Extension of anonymous methods
    • Advancement of Delegates
    • Is an inline expression / statement block
      • with a concise syntax that can be used wherever a delegate or anonymous method is expected
      • which can be used to pass arguments to method call or assign value to delegate
    • Expression use “=>” operator
      • Left side denotes result
      • Right side contains statement block or expression
  • 27. Lambda Expressions // Data source. int[] Scores = { 90, 71, 82, 93, 75, 82 }; Write me some code that returns me the count for the numbers that are greater than 80 ? // This query executes immediately because it returns a singleton int value, not an iterable sequence. int scoreQuery = Scores.Where(n => n > 80).Count();
  • 28. Lambda Expressions // Data source. string[] Projects = { “eZCap”, “iMedsoft”, “Patient Portal”, “LiveWellHRA”, “ETL”, “iMedLiveWell”}; Write me some code that returns me the projects that has “Med” in project name ? IEnumerable<string> projsQry = from proj in projs where proj.Contains(&quot;Med&quot;) select proj; foreach (string projName in projsQry) { Console.WriteLine(projName); }
  • 29. λ Lambda Expressions – conti ..
    • Improved type inference
    • Conversion for both delegate types as well as expression trees
    • Expression trees ??
      • Lambda expressions with an expression body can be converted to expression tree
    • General rules
      • Must contain same number of parameters as the delegate type
      • Each parameter and return value must be implicitly convertible to its corresponding delegate parameter or delegate return type
  • 30. demo Lambda Expressions
    • Delegates
    • Anonymous Methods
    • Lambda Expressions
  • 31. Agenda
    • What’s new in Orcas
    • C# 3.0
      • Implicit Variables
      • Auto implemented properties
      • Object & Collection Initializers
      • Extension Methods
      • Anonymous Types / Tuples
      • Lambda Expressions
      • Generic Delegates (Func)
      • Expression Methods
      • Partial Methods
  • 32. Generic Delegates (Func)
    • Allows to construct a method with out declaring delegate
    • 5 predefined generic delegates
    • Last parameter is always return type
    • You can extend them with LINQ
      • Func<>
  • 33. demo Generic Delegates
    • Func<string, string>
  • 34. Agenda
    • What’s new in Orcas
    • C# 3.0
      • Implicit Variables
      • Auto implemented properties
      • Object & Collection Initializers
      • Extension Methods
      • Anonymous Types / Tuples
      • Lambda Expressions
      • Generic Delegates (Func)
      • Expression Trees
      • Partial Methods
  • 35. Expression Trees
    • Don’t get confuse System.LINQ.Expression with Windows.Forms
    • Allow lamda expressions as data instead of code
      • Expression<>
  • 36. demo Expression Trees
    • Expression<Func<string, string>>
    • Expression.Compile
  • 37. Q&A
  • 38. For further win/win
    • var WhoIsThereNextMonth = new {
    • Default = “Chakravarthy”,
    • Perhaps = “Sarma & Siva”,
    • AreYou =“NotSure”,
    • Topics =“What do you Want ??”,
    • AnyThing =“Don’t hesitate, ASK ME”
    • }
  • 39. Where to go for any technical
    • Post your message at http:// groups.msn.com/CSharpGroup
    • Drop me a line at chakravarthy.dsk@inteq
    • Visit our sessions on “KS” Knowledge Share with out fail
  • 40. Next ???

×