Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

What's new in c# 6

546 views

Published on

Presentation about the new features in C# 6

Published in: Software
  • Hello there! Get Your Professional Job-Winning Resume Here! http://bit.ly/topresum
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

What's new in c# 6

  1. 1. WHAT’S NEW IN C# 6
  2. 2. STRING INTERPOLATION
  3. 3. No Interpolation
  4. 4. Concatenation
  5. 5. String.Format
  6. 6. $”Hello {var1}” C# 6.0
  7. 7. $”Value of {price:C2}” C# 6.0
  8. 8. NULL CONDITIONAL OPERATOR
  9. 9. Checking for null
  10. 10. Is a drag
  11. 11. Don’t check
  12. 12. Shortcircuit to null
  13. 13. perhapsNull?.FullName() C# 6.0
  14. 14. USING STATIC
  15. 15. Static methods have to be always qualified
  16. 16. Enumerable.Empty<T>
  17. 17. using static Enumerable; C# 6.0
  18. 18. Empty<T> C# 6.0
  19. 19. AUTOPROPERTIES INITIZALITION
  20. 20. Getter and Setter declaration
  21. 21. Initialize in the constructor
  22. 22. string Name {get; set;} = “Harry” C# 6.0
  23. 23. GETTER ONLY INITIALIZATION
  24. 24. Getter declaration
  25. 25. Initialize in constructor
  26. 26. string Name {get;} = “Harry” C# 6.0
  27. 27. EXPRESSION BODIES ON METHODS
  28. 28. Methods always need a body
  29. 29. No matter how short
  30. 30. void Method() => expr C# 6.0
  31. 31. EXPRESSION BODIES ON PROPERTIES
  32. 32. Properties always need a body
  33. 33. No matter how short
  34. 34. void Property => expo C# 6.0
  35. 35. NAMEOF EXPRESSIONS
  36. 36. Using hardcoded strings to refer to expressions
  37. 37. Is error prone
  38. 38. Wrong spelling
  39. 39. Variable changes
  40. 40. nameof(var.FirstName) C# 6.0
  41. 41. EXCEPTION FILTERS
  42. 42. Similar to VB.NET and F#
  43. 43. Exception catch block can have a guard
  44. 44. try {…} catch (Exception e) when (expr) { … } C# 6.0
  45. 45. INDEX INITIALIZER
  46. 46. Simplify dictionary initialization
  47. 47. var numbers = new Dictionary<int, string> { [7] = "seven", [9] = "nine", [13] = "thirteen" }; C# 6.0
  48. 48. AWAIT ON CATCH/FINALLY BLOCKS
  49. 49. Similar to F#
  50. 50. Catch and Finally blocks can have Await calls
  51. 51. Resource res = null; 
 try
 {
 res = await Resource.OpenAsync(…); 
 …
 } 
 catch(ResourceException e)
 {
 await Resource.LogAsync(res, e); 
 }
 finally
 {
 if (res != null) await res.CloseAsync(); 
 } C# ????
  52. 52. PRIMARY CONSTRUCTORS
  53. 53. Simplify constructor declaration
  54. 54. public class Post(long postId, string name, string title)
 {
 public long PostID { get; } = postId;
 public string PostName { get; } = name;
 public string PostTitle { get; } = title;
 } C# ????
  55. 55. INDEXED PROPERTY OPERATOR
  56. 56. Simplify Dictionary initialization
  57. 57. dict[“Harry”]
  58. 58. dict.$Harry C# ????
  59. 59. THANK YOU!
  60. 60. The Smartest tool for agile project management http://smartview.io
  61. 61. amir@barylko.com @abarylko http://bit.ly/abarylkoslides http://orthocoders.com http://westerndevs.com
  62. 62. Resources • Github Wiki C# 6 language features: http://bit.ly/Csharp6_features • MSDN C# 6 features: http://bit.ly/csharp6_msdn • C# 6.0 in six screenshots: http://bit.ly/csharp_screenshots
  63. 63. Photo Credit • Under http://creativecommons.org/licenses/by/2.5/ • Jeremy Keith, Roast beef, http://flic.kr/p/TKUz • Rob Campbell, Field of daisies, http://flic.kr/p/6QJjU4

×