SlideShare una empresa de Scribd logo
1 de 41
Descargar para leer sin conexión
#mstechdays techdays.microsoft.fr
Agenda
• Introduction: evolution of C#
• C# 6.0
• Getter-only auto-properties
• Initializers for auto-properties
• Using static classes
• String interpolation
• Expression-bodied methods
• Expression-bodied properties
• Index initializers
• Null-conditional operator
• Nameof operator
• Exception filter
• Q&A
The Evolution of C#
C# 1.0
C# 2.0
C# 3.0
Managed Code
Generics
Language Integrated Query
C# 4.0
Dynamic Programming
C# 5.0
Asynchrony (await)
.Net Compiler Platform: Roslyn
•INTRODUCTION
•EXPOSING THE COMPILER APIS
• COMPILER PIPELINE FUNCTIONAL AREAS
• API LAYERS
• Compiler APIs
• Workspaces APIs
•WORKING WITH SYNTAX
• SYNTAX TREES
• SYNTAX NODES
• SYNTAX TOKENS
• SYNTAX TRIVIA
• SPANS
• KINDS
• ERRORS
•WORKING WITH SEMANTICS
• COMPILATION
• SYMBOLS
• SEMANTIC MODEL
•WORKING WITH A WORKSPACE
• WORKSPACE
• SOLUTIONS, PROJECTS, DOCUMENTS
•SUMMARY
Getter-only auto-properties
public class Point
{
public int X { get; set; }
public int Y { get; set; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Math.Sqrt(X * X + Y * Y); }
}
public override string ToString()
{
return String.Format("({0}, {1})", X, Y);
}
}
Getter-only auto-properties
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Math.Sqrt(X * X + Y * Y); }
}
public override string ToString()
{
return String.Format("({0}, {1})", X, Y);
}
}
Getter-only auto-properties
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Math.Sqrt(X * X + Y * Y); }
}
public override string ToString()
{
return String.Format("({0}, {1})", X, Y);
}
}
Initializers for auto-properties
public class Point
{
public int X { get; } = 5;
public int Y { get; } = 7;
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Math.Sqrt(X * X + Y * Y); }
}
public override string ToString()
{
return String.Format("({0}, {1})", X, Y);
}
}
Using static classes
using System.Math;
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Math.Sqrt(X * X + Y * Y); }
}
public override string ToString()
{
return String.Format("({0}, {1})", X, Y);
}
}
Using static classes
using System.Math;
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Math.Sqrt(X * X + Y * Y); }
}
public override string ToString()
{
return String.Format("({0}, {1})", X, Y);
}
}
Using static classes
using System.Math;
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Sqrt(X * X + Y * Y); }
}
public override string ToString()
{
return String.Format("({0}, {1})", X, Y);
}
}
String interpolation
using System.Math;
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Sqrt(X * X + Y * Y); }
}
public override string ToString()
{
return String.Format("({0}, {1})", X, Y);
}
}
String interpolation
using System.Math;
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Sqrt(X * X + Y * Y); }
}
public override string ToString()
{
return "({X}, {Y})";
}
}
Expression-bodied methods
using System.Math;
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Sqrt(X * X + Y * Y); }
}
public override string ToString()
{
return "({X}, {Y})";
}
}
Expression-bodied methods
using System.Math;
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Sqrt(X * X + Y * Y); }
}
public override string ToString()
{
return "({X}, {Y})";
}
}
() => { return "({X}, {Y})"; }
() => "({X}, {Y})"
Expression-bodied methods
using System.Math;
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Sqrt(X * X + Y * Y); }
}
public override string ToString() => "({X}, {Y})";
}
Expression-bodied properties
using System.Math;
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist
{
get { return Sqrt(X * X + Y * Y); }
}
public override string ToString() => "({X}, {Y})";
}
Expression-bodied properties
using System.Math;
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist => Sqrt(X * X + Y * Y);
public override string ToString() => "({X}, {Y})";
}
Expression-bodied properties
using System.Math;
public class Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y) { X = x; Y = y; }
public double Dist => Sqrt(X * X + Y * Y);
public override string ToString() => "({X}, {Y})";
}
Index initializers
public class Point
{
public int X { get; }
public int Y { get; }
…
public JObject ToJson()
{
var result = new JObject();
result["x"] = X;
result["y"] = Y;
return result;
}
}
Index initializers
public class Point
{
public int X { get; }
public int Y { get; }
…
public JObject ToJson()
{
var result = new JObject() { ["x"] = X, ["y"] = Y };
return result;
}
}
Index initializers
public class Point
{
public int X { get; }
public int Y { get; }
…
public JObject ToJson()
{
return new JObject() { ["x"] = X, ["y"] = Y };
}
}
Index initializers
public class Point
{
public int X { get; }
public int Y { get; }
…
public JObject ToJson() =>
new JObject() { ["x"] = X, ["y"] = Y };
}
Null-conditional operators
public static Point FromJson(JObject json)
{
if (json != null &&
json["x"] != null &&
json["x"].Type == JTokenType.Integer &&
json["y"] != null &&
json["y"].Type == JTokenType.Integer)
{
return new Point((int)json["x"], (int)json["y"]);
}
return null;
}
Null-conditional operators
public static Point FromJson(JObject json)
{
if (json != null &&
json["x"]?.Type == JTokenType.Integer &&
json["y"]?.Type == JTokenType.Integer)
{
return new Point((int)json["x"], (int)json["y"]);
}
return null;
}
Null-conditional operators
public static Point FromJson(JObject json)
{
if (json != null &&
json["x"]?.Type == JTokenType.Integer &&
json["y"]?.Type == JTokenType.Integer)
{
return new Point((int)json["x"], (int)json["y"]);
}
return null;
}
?.
Null-conditional operators
public static Point FromJson(JObject json)
{
if (json != null &&
json["x"]?.Type == JTokenType.Integer &&
json["y"]?.Type == JTokenType.Integer)
{
return new Point((int)json["x"], (int)json["y"]);
}
return null;
}
Null-conditional operators
public static Point FromJson(JObject json)
{
if (json?["x"]?.Type == JTokenType.Integer &&
json?["y"]?.Type == JTokenType.Integer)
{
return new Point((int)json["x"], (int)json["y"]);
}
return null;
}
Null-conditional operators
OnChanged(this, args);
Null-conditional operators
if (OnChanged != null)
{
OnChanged(this, args);
}
Null-conditional operators
{
var onChanged = OnChanged;
if (onChanged != null)
{
onChanged(this, args);
}
}
Null-conditional operators
OnChanged?.Invoke(this, args);
The nameof operator
public Point Add(Point point)
{
if (point == null)
{
throw new ArgumentNullException("point");
}
}
The nameof operator
public Point Add(Point other)
{
if (other == null)
{
throw new ArgumentNullException("point");
}
}
The nameof operator
public Point Add(Point point)
{
if (point == null)
{
throw new ArgumentNullException(nameof(point));
}
}
The nameof operator
public Point Add(Point other)
{
if (other == null)
{
throw new ArgumentNullException(nameof(other));
}
}
Exception filters
try
{
…
}
catch (ConfigurationException e)
{
}
finally
{
}
Exception filters
try
{
…
}
catch (ConfigurationException e) if (e.IsSevere)
{
}
finally
{
}
Await in catch and finally
try
{
…
}
catch (ConfigurationException e) if (e.IsSevere)
{
await LogAsync(e);
}
finally
{
await CloseAsync();
}
roslyn.codeplex.com
Learn more at …
© 2015 Microsoft Corporation. All rights reserved.
tech days•
2015
#mstechdays techdays.microsoft.fr

Más contenido relacionado

La actualidad más candente

Java Puzzle
Java PuzzleJava Puzzle
Java Puzzle
SFilipp
 

La actualidad más candente (20)

Kotlin, why?
Kotlin, why?Kotlin, why?
Kotlin, why?
 
Chapter 4 - Classes in Java
Chapter 4 - Classes in JavaChapter 4 - Classes in Java
Chapter 4 - Classes in Java
 
The Ring programming language version 1.5.2 book - Part 32 of 181
The Ring programming language version 1.5.2 book - Part 32 of 181The Ring programming language version 1.5.2 book - Part 32 of 181
The Ring programming language version 1.5.2 book - Part 32 of 181
 
The Ring programming language version 1.3 book - Part 24 of 88
The Ring programming language version 1.3 book - Part 24 of 88The Ring programming language version 1.3 book - Part 24 of 88
The Ring programming language version 1.3 book - Part 24 of 88
 
The Ring programming language version 1.5.3 book - Part 33 of 184
The Ring programming language version 1.5.3 book - Part 33 of 184The Ring programming language version 1.5.3 book - Part 33 of 184
The Ring programming language version 1.5.3 book - Part 33 of 184
 
OOP v3
OOP v3OOP v3
OOP v3
 
The Ring programming language version 1.5.1 book - Part 31 of 180
The Ring programming language version 1.5.1 book - Part 31 of 180The Ring programming language version 1.5.1 book - Part 31 of 180
The Ring programming language version 1.5.1 book - Part 31 of 180
 
The Ring programming language version 1.2 book - Part 22 of 84
The Ring programming language version 1.2 book - Part 22 of 84The Ring programming language version 1.2 book - Part 22 of 84
The Ring programming language version 1.2 book - Part 22 of 84
 
The Ring programming language version 1.6 book - Part 32 of 189
The Ring programming language version 1.6 book - Part 32 of 189The Ring programming language version 1.6 book - Part 32 of 189
The Ring programming language version 1.6 book - Part 32 of 189
 
Object calisthenics
Object calisthenicsObject calisthenics
Object calisthenics
 
Java Puzzle
Java PuzzleJava Puzzle
Java Puzzle
 
Computer java programs
Computer java programsComputer java programs
Computer java programs
 
Scala best practices
Scala best practicesScala best practices
Scala best practices
 
The Ring programming language version 1.8 book - Part 35 of 202
The Ring programming language version 1.8 book - Part 35 of 202The Ring programming language version 1.8 book - Part 35 of 202
The Ring programming language version 1.8 book - Part 35 of 202
 
The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.5.3 book - Part 30 of 184The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.5.3 book - Part 30 of 184
 
18. Java associative arrays
18. Java associative arrays18. Java associative arrays
18. Java associative arrays
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
 
Array
ArrayArray
Array
 
The Ring programming language version 1.7 book - Part 34 of 196
The Ring programming language version 1.7 book - Part 34 of 196The Ring programming language version 1.7 book - Part 34 of 196
The Ring programming language version 1.7 book - Part 34 of 196
 
Haskell 101
Haskell 101Haskell 101
Haskell 101
 

Destacado

Destacado (7)

De A à Z: Accès aux données avec Entity Framework 4.2 et publication en OData
De A à Z: Accès aux données avec Entity Framework 4.2 et publication en ODataDe A à Z: Accès aux données avec Entity Framework 4.2 et publication en OData
De A à Z: Accès aux données avec Entity Framework 4.2 et publication en OData
 
Keynote développement mobile : les solutions pour Windows (Phone), Android et...
Keynote développement mobile : les solutions pour Windows (Phone), Android et...Keynote développement mobile : les solutions pour Windows (Phone), Android et...
Keynote développement mobile : les solutions pour Windows (Phone), Android et...
 
365 raisons d’inclure Office365 dans vos apps mobiles (Authentifications, Lis...
365 raisons d’inclure Office365 dans vos apps mobiles (Authentifications, Lis...365 raisons d’inclure Office365 dans vos apps mobiles (Authentifications, Lis...
365 raisons d’inclure Office365 dans vos apps mobiles (Authentifications, Lis...
 
Découverte du moteur de rendu du projet Spartan
Découverte du moteur de rendu du projet SpartanDécouverte du moteur de rendu du projet Spartan
Découverte du moteur de rendu du projet Spartan
 
Faites comme Netflix, voire mieux : diffuser de la VOD et du Live dans le mon...
Faites comme Netflix, voire mieux : diffuser de la VOD et du Live dans le mon...Faites comme Netflix, voire mieux : diffuser de la VOD et du Live dans le mon...
Faites comme Netflix, voire mieux : diffuser de la VOD et du Live dans le mon...
 
Solutions et méthodes pour accélérer le déploiement de Lync
Solutions  et méthodes pour accélérer le déploiement de LyncSolutions  et méthodes pour accélérer le déploiement de Lync
Solutions et méthodes pour accélérer le déploiement de Lync
 
Python dans le cloud avec Windows Azure
Python dans le cloud avec Windows AzurePython dans le cloud avec Windows Azure
Python dans le cloud avec Windows Azure
 

Similar a Les nouveautés de C# 6

C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
Paulo Morgado
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
ShashikantSathe3
 
Point.javapublic class Point {    int x,y;    double m,n; .pdf
Point.javapublic class Point {    int x,y;    double m,n; .pdfPoint.javapublic class Point {    int x,y;    double m,n; .pdf
Point.javapublic class Point {    int x,y;    double m,n; .pdf
anokhilalmobile
 

Similar a Les nouveautés de C# 6 (20)

TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
 
New C# features
New C# featuresNew C# features
New C# features
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
 
662305 10
662305 10662305 10
662305 10
 
C sharp 8
C sharp 8C sharp 8
C sharp 8
 
Java Class Design
Java Class DesignJava Class Design
Java Class Design
 
Comp102 lec 7
Comp102   lec 7Comp102   lec 7
Comp102 lec 7
 
Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performance
 
Monadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query ExpressionsMonadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query Expressions
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Point.javapublic class Point {    int x,y;    double m,n; .pdf
Point.javapublic class Point {    int x,y;    double m,n; .pdfPoint.javapublic class Point {    int x,y;    double m,n; .pdf
Point.javapublic class Point {    int x,y;    double m,n; .pdf
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
First few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesFirst few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examples
 
[Codemotion 2015] patrones de diseño con java8
[Codemotion 2015] patrones de diseño con java8[Codemotion 2015] patrones de diseño con java8
[Codemotion 2015] patrones de diseño con java8
 
Operator overloading (binary)
Operator overloading (binary)Operator overloading (binary)
Operator overloading (binary)
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
Pragmatic metaprogramming
Pragmatic metaprogrammingPragmatic metaprogramming
Pragmatic metaprogramming
 
Functional Programming with C#
Functional Programming with C#Functional Programming with C#
Functional Programming with C#
 
Parameters
ParametersParameters
Parameters
 

Más de Microsoft

Más de Microsoft (20)

Uwp + Xamarin : Du nouveau en terre du milieu
Uwp + Xamarin : Du nouveau en terre du milieuUwp + Xamarin : Du nouveau en terre du milieu
Uwp + Xamarin : Du nouveau en terre du milieu
 
La Blockchain pas à PaaS
La Blockchain pas à PaaSLa Blockchain pas à PaaS
La Blockchain pas à PaaS
 
Tester, Monitorer et Déployer son application mobile
Tester, Monitorer et Déployer son application mobileTester, Monitorer et Déployer son application mobile
Tester, Monitorer et Déployer son application mobile
 
Windows 10, un an après – Nouveautés & Démo
Windows 10, un an après – Nouveautés & Démo Windows 10, un an après – Nouveautés & Démo
Windows 10, un an après – Nouveautés & Démo
 
Prenez votre pied avec les bots et cognitive services.
Prenez votre pied avec les bots et cognitive services.Prenez votre pied avec les bots et cognitive services.
Prenez votre pied avec les bots et cognitive services.
 
Office 365 Dev PnP & PowerShell : exploitez enfin le potentiel de votre écosy...
Office 365 Dev PnP & PowerShell : exploitez enfin le potentiel de votre écosy...Office 365 Dev PnP & PowerShell : exploitez enfin le potentiel de votre écosy...
Office 365 Dev PnP & PowerShell : exploitez enfin le potentiel de votre écosy...
 
Créer un bot de A à Z
Créer un bot de A à ZCréer un bot de A à Z
Créer un bot de A à Z
 
Microsoft Composition, pierre angulaire de vos applications ?
Microsoft Composition, pierre angulaire de vos applications ?Microsoft Composition, pierre angulaire de vos applications ?
Microsoft Composition, pierre angulaire de vos applications ?
 
Les nouveautés SQL Server 2016
Les nouveautés SQL Server 2016Les nouveautés SQL Server 2016
Les nouveautés SQL Server 2016
 
Conteneurs Linux ou Windows : quelles approches pour des IT agiles ?
Conteneurs Linux ou Windows : quelles approches pour des IT agiles ?Conteneurs Linux ou Windows : quelles approches pour des IT agiles ?
Conteneurs Linux ou Windows : quelles approches pour des IT agiles ?
 
Administration et supervision depuis le Cloud avec Azure Logs Analytics
Administration et supervision depuis le Cloud avec Azure Logs AnalyticsAdministration et supervision depuis le Cloud avec Azure Logs Analytics
Administration et supervision depuis le Cloud avec Azure Logs Analytics
 
Retour d'expérience de projets Azure IoT "large scale" (MicroServices, portag...
Retour d'expérience de projets Azure IoT "large scale" (MicroServices, portag...Retour d'expérience de projets Azure IoT "large scale" (MicroServices, portag...
Retour d'expérience de projets Azure IoT "large scale" (MicroServices, portag...
 
Plan de Reprise d'Activité avec Azure Site Recovery
Plan de Reprise d'Activité avec Azure Site RecoveryPlan de Reprise d'Activité avec Azure Site Recovery
Plan de Reprise d'Activité avec Azure Site Recovery
 
Modélisation, déploiement et gestion des infrastructures Cloud : outils et bo...
Modélisation, déploiement et gestion des infrastructures Cloud : outils et bo...Modélisation, déploiement et gestion des infrastructures Cloud : outils et bo...
Modélisation, déploiement et gestion des infrastructures Cloud : outils et bo...
 
Transformation de la représentation : De la VR à la RA, aller & retour.
Transformation de la représentation : De la VR à la RA, aller & retour.Transformation de la représentation : De la VR à la RA, aller & retour.
Transformation de la représentation : De la VR à la RA, aller & retour.
 
Quelles architectures pour vos applications Cloud, de la VM au conteneur : ça...
Quelles architectures pour vos applications Cloud, de la VM au conteneur : ça...Quelles architectures pour vos applications Cloud, de la VM au conteneur : ça...
Quelles architectures pour vos applications Cloud, de la VM au conteneur : ça...
 
Introduction à ASP.NET Core
Introduction à ASP.NET CoreIntroduction à ASP.NET Core
Introduction à ASP.NET Core
 
Open Source et Microsoft Azure, rêve ou réalité ?
Open Source et Microsoft Azure, rêve ou réalité ?Open Source et Microsoft Azure, rêve ou réalité ?
Open Source et Microsoft Azure, rêve ou réalité ?
 
Comment développer sur la console Xbox One avec une application Universal Win...
Comment développer sur la console Xbox One avec une application Universal Win...Comment développer sur la console Xbox One avec une application Universal Win...
Comment développer sur la console Xbox One avec une application Universal Win...
 
Azure Service Fabric pour les développeurs
Azure Service Fabric pour les développeursAzure Service Fabric pour les développeurs
Azure Service Fabric pour les développeurs
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Les nouveautés de C# 6

  • 2. Agenda • Introduction: evolution of C# • C# 6.0 • Getter-only auto-properties • Initializers for auto-properties • Using static classes • String interpolation • Expression-bodied methods • Expression-bodied properties • Index initializers • Null-conditional operator • Nameof operator • Exception filter • Q&A
  • 3. The Evolution of C# C# 1.0 C# 2.0 C# 3.0 Managed Code Generics Language Integrated Query C# 4.0 Dynamic Programming C# 5.0 Asynchrony (await)
  • 4. .Net Compiler Platform: Roslyn •INTRODUCTION •EXPOSING THE COMPILER APIS • COMPILER PIPELINE FUNCTIONAL AREAS • API LAYERS • Compiler APIs • Workspaces APIs •WORKING WITH SYNTAX • SYNTAX TREES • SYNTAX NODES • SYNTAX TOKENS • SYNTAX TRIVIA • SPANS • KINDS • ERRORS •WORKING WITH SEMANTICS • COMPILATION • SYMBOLS • SEMANTIC MODEL •WORKING WITH A WORKSPACE • WORKSPACE • SOLUTIONS, PROJECTS, DOCUMENTS •SUMMARY
  • 5. Getter-only auto-properties public class Point { public int X { get; set; } public int Y { get; set; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Math.Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); } }
  • 6. Getter-only auto-properties public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Math.Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); } }
  • 7. Getter-only auto-properties public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Math.Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); } }
  • 8. Initializers for auto-properties public class Point { public int X { get; } = 5; public int Y { get; } = 7; public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Math.Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); } }
  • 9. Using static classes using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Math.Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); } }
  • 10. Using static classes using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Math.Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); } }
  • 11. Using static classes using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); } }
  • 12. String interpolation using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() { return String.Format("({0}, {1})", X, Y); } }
  • 13. String interpolation using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() { return "({X}, {Y})"; } }
  • 14. Expression-bodied methods using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() { return "({X}, {Y})"; } }
  • 15. Expression-bodied methods using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() { return "({X}, {Y})"; } } () => { return "({X}, {Y})"; } () => "({X}, {Y})"
  • 16. Expression-bodied methods using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() => "({X}, {Y})"; }
  • 17. Expression-bodied properties using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist { get { return Sqrt(X * X + Y * Y); } } public override string ToString() => "({X}, {Y})"; }
  • 18. Expression-bodied properties using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist => Sqrt(X * X + Y * Y); public override string ToString() => "({X}, {Y})"; }
  • 19. Expression-bodied properties using System.Math; public class Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public double Dist => Sqrt(X * X + Y * Y); public override string ToString() => "({X}, {Y})"; }
  • 20. Index initializers public class Point { public int X { get; } public int Y { get; } … public JObject ToJson() { var result = new JObject(); result["x"] = X; result["y"] = Y; return result; } }
  • 21. Index initializers public class Point { public int X { get; } public int Y { get; } … public JObject ToJson() { var result = new JObject() { ["x"] = X, ["y"] = Y }; return result; } }
  • 22. Index initializers public class Point { public int X { get; } public int Y { get; } … public JObject ToJson() { return new JObject() { ["x"] = X, ["y"] = Y }; } }
  • 23. Index initializers public class Point { public int X { get; } public int Y { get; } … public JObject ToJson() => new JObject() { ["x"] = X, ["y"] = Y }; }
  • 24. Null-conditional operators public static Point FromJson(JObject json) { if (json != null && json["x"] != null && json["x"].Type == JTokenType.Integer && json["y"] != null && json["y"].Type == JTokenType.Integer) { return new Point((int)json["x"], (int)json["y"]); } return null; }
  • 25. Null-conditional operators public static Point FromJson(JObject json) { if (json != null && json["x"]?.Type == JTokenType.Integer && json["y"]?.Type == JTokenType.Integer) { return new Point((int)json["x"], (int)json["y"]); } return null; }
  • 26. Null-conditional operators public static Point FromJson(JObject json) { if (json != null && json["x"]?.Type == JTokenType.Integer && json["y"]?.Type == JTokenType.Integer) { return new Point((int)json["x"], (int)json["y"]); } return null; } ?.
  • 27. Null-conditional operators public static Point FromJson(JObject json) { if (json != null && json["x"]?.Type == JTokenType.Integer && json["y"]?.Type == JTokenType.Integer) { return new Point((int)json["x"], (int)json["y"]); } return null; }
  • 28. Null-conditional operators public static Point FromJson(JObject json) { if (json?["x"]?.Type == JTokenType.Integer && json?["y"]?.Type == JTokenType.Integer) { return new Point((int)json["x"], (int)json["y"]); } return null; }
  • 30. Null-conditional operators if (OnChanged != null) { OnChanged(this, args); }
  • 31. Null-conditional operators { var onChanged = OnChanged; if (onChanged != null) { onChanged(this, args); } }
  • 33. The nameof operator public Point Add(Point point) { if (point == null) { throw new ArgumentNullException("point"); } }
  • 34. The nameof operator public Point Add(Point other) { if (other == null) { throw new ArgumentNullException("point"); } }
  • 35. The nameof operator public Point Add(Point point) { if (point == null) { throw new ArgumentNullException(nameof(point)); } }
  • 36. The nameof operator public Point Add(Point other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } }
  • 39. Await in catch and finally try { … } catch (ConfigurationException e) if (e.IsSevere) { await LogAsync(e); } finally { await CloseAsync(); }
  • 41. © 2015 Microsoft Corporation. All rights reserved. tech days• 2015 #mstechdays techdays.microsoft.fr