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.

C# 6.0 and 7.0 new features


Published on

Slides de la charla de C# 6 / 7 new features impartida en MadridDotNet.

Video de la charla:

Enlace de la charla:

Descripción de la charla:

En esta charla repasaremos las features que el equipo de C# incluyo en la versión 6.0 y abordaremos las nuevas features de C# 7.0 escribiendo código en vivo para comprender estas nuevas características del lenguaje.

C# 6.0 Features

Null-Conditional Operator

Null Coalescing Operator

Auto-Property Initializers

Using static

Nameof Expressions

Exception filters

Await in catch and finally blocks

Expression Bodied Functions and Properties

String interpolation

C# 7.0 Features

Expresion bodied members

Pattern Matching (Is)

Pattern Matching (Switch)

Local Functions

Inline Out variables

Returns by reference

Throw expressions



Async return types (ValueTask)


Carlos Landeras Martínez

Software Engineer en Plain Concepts

Más de 9 años de experiencia en tecnologías .NET y desarrollo de aplicaciones Web. Apasionado de las nuevas arquitecturas y herramientas Front-End.

Published in: Software
  • Be the first to comment

C# 6.0 and 7.0 new features

  1. 1. C# 6.0 & 7.0 Features
  2. 2. Carlos Landeras Martínez Software Engineer at Plain Concepts @carlos_lande ¿Who Am I?
  3. 3. A little bit of C# History
  4. 4. What’s What was new in C# 6.0 Read-only auto-properties Auto-Property Initializers Expression-bodied function members Using Static Null – Conditional Operators String Interpolation Exception filters nameof Expressions Await in catch and finally blocks Index initializers
  5. 5. Read Only Auto Properties Read-only auto-properties provide a more concise syntax to create immutable types, in previous C# Versions the compiler only enforces properties not to be modified outside the class. Read Only Auto Properties, enable true read-only behaviour, and true language support for immutable types Note* : Read Only properties must be set inside the body of class constructor, trying to set them in other block of code would end with a CS 0200 compilation error
  6. 6. Auto Property Initializers Allows initialization of an Auto Property as part of the property declaration.
  7. 7. Expression bodied Function Members The body of a lot of members that we write consist of only one statement that can be represented as an expression
  8. 8. Using Static The using static enhancement enables you to import the static methods of a single class.
  9. 9. Null Conditional Operator Stop complicating your code by checking Null when accessing variables!. Yiiiiihaaaa!
  10. 10. String Interpolation Welcome to the new Syntax for composing strings!
  11. 11. Exception filters Determine when a given catch clause should be applied
  12. 12. Nameof Expression The nameof expression evaluates to the name of a symbol
  13. 13. Await in catch and finally blocks C# 6.0 allows to use await keyword y catch and finally blocks.
  14. 14. Index Initializers Allow collection initialization to be more consistent. In earlier versions, we could use collection initializers with sequence style collections, now we can even use them with Dictionaries.
  15. 15. What is new in C# 7.0 Expresion bodied members Pattern Matching (Is) Pattern Matching (Switch) Local Functions Inline Out variables Returns by reference Throw expressions Tuples Deconstructions Async return types (ValueTask)
  16. 16. Expression bodied members In C# 6.0 we had expression bodied function members, and this version has added accessors, constructors and finalizers
  17. 17. Pattern Matching (is) Syntactic elements that can test that a value has a certain “shape”, and extract information from the value when it does.
  18. 18. Pattern Matching (Switch) You can now switch on any type, not just primitive types. Patterns can use case clauses, and this clauses can have additional conditions on them.
  19. 19. Local functions If your helper function only makes sense inside the single method that is consuming it. You can now declare it as a local function.
  20. 20. Inline out variables Before C# 6.0, you had to declare variables you pass to out parameters, it is a little bit pointless since this value will be overwritten. In C# 7.0 you can declare and use them inline.
  21. 21. Throw expressions It is now possible to throw an exception in the middle of an expression ;)
  22. 22. Tuples and deconstructions Tuples have arrived to C# 7.0!. You can stop creating dummy objects to return more than one value. The options until now were: • System.Tuple (Verbose and require allocation) • Out parameters (Use is awkward, not working in async methods) • Anonymous types through a dynamic. (overhead and no type checking) Tuples are a new value type in C# language. This means Performance (no overhead like old Tuple, that stored a class instance) and new software design capabilities.
  23. 23. Async return types C# 7.0 introduces ValueTask. The main advantage of this new struct, it’s to prevent the Allocation of a new Task<T> object in cases where the result of the async operation is already available at the time of awaiting.