SlideShare a Scribd company logo
C# C# 6.0
Ricardo Gonzalez Vargas
Microsoft Regional Director - Bogota
CEO – Androcial / WomyAds.com
Sénior IT Architecture & SD Consultant
http://about.me/ricardo.gonzalez
C#
Quien les habla?
C#
Agenda
• Evolución de C#
• C# 6.0 = C# + Roslyn
• Nuevas características
• Ejemplos
C#
Evolución de C#
C# 1.0 /
Managed
Code
C# 2.0 /
Generics
C# 3.0 / LINQ
C# 4.0 /
Dynamic
Programming
C# 5.0 / Async
Programming –
Windows
Runtime
C# 6.0 /
Compiler
Platform
C#
C# 6.0 y Roslyn
• Reimplementacion del compilador del lenguaje, escrito en el mismo
lenguaje
• Expone APIs para diferentes niveles de abstracción del proceso de
compilación
• Permite, análisis, diagnostico, manipulación y generación del código
basado en los servicios de lenguaje
C#
Filosofia de diseno
 No hay conceptos muy cambiantes
 Muchas funcionalidades pequeñas
 Enfocado en hacer mas limpio el código
C#
Propiedades automaticas de solo lectura
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);
}
}
C#
Propiedades automaticas de solo lectura
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);
}
}
C#
Propiedades automaticas de solo lectura
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);
}
}
C#
Inicializadores para propiedades automaticas
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);
}
}
C#
Uso de clases estaticas
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);
}
}
C#
Uso de clases estaticas
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);
}
}
C#
Uso de clases estaticas
using static 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);
}
}
C#
Interpolación de cadenas
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);
}
}
C#
Interpolacion de cadenas
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})";
}
}
C#
Metodos con expresiones como cuerpo
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})";
}
}
C#
Metodos con expresiones como cuerpo
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})"
C#
Metodos con expresiones como cuerpo
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})";
}
C#
Propiedades con expresiones como cuerpo
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})";
}
C#
Propiedades con expresiones como cuerpo
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})";
}
C#
Propiedades con expresiones como cuerpo
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})";
}
C#
Inicializadores de Indices
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;
}
}
C#
Inicializadores de Indices
public class Point
{
public int X { get; }
public int Y { get; }
…
public JObject ToJson()
{
var result = new JObject() { ["x"] = X, ["y"] = Y };
return result;
}
}
C#
Inicializadores de Indices
public class Point
{
public int X { get; }
public int Y { get; }
…
public JObject ToJson()
{
return new JObject() { ["x"] = X, ["y"] = Y };
}
}
C#
Inicializadores de Indices
public class Point
{
public int X { get; }
public int Y { get; }
…
public JObject ToJson() =>
new JObject() { ["x"] = X, ["y"] = Y };
}
C#
Operadores condicionados con null
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;
}
C#
Operadores condicionados con null
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;
}
C#
Operadores condicionados con null
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;
}
?.
C#
Operadores condicionados con null
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;
}
C#
Operadores condicionados con null
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;
}
C#
Operadores condicionados con null
OnChanged(this, args);
C#
Operadores condicionados con null
if (OnChanged != null)
{
OnChanged(this, args);
}
C#
Operadores condicionados con null
{
var onChanged = OnChanged;
if (onChanged != null)
{
onChanged(this, args);
}
}
C#
Operadores condicionados con null
OnChanged?.Invoke(this, args);
C#
Operador nameOf
public Point Add(Point point)
{
if (point == null)
{
throw new ArgumentNullException("point");
}
}
C#
Operador nameOf
public Point Add(Point other)
{
if (other == null)
{
throw new ArgumentNullException("point");
}
}
C#
Operador nameOf
public Point Add(Point point)
{
if (point == null)
{
throw new ArgumentNullException(nameof(point));
}
}
C#
Operador nameOf
public Point Add(Point other)
{
if (other == null)
{
throw new ArgumentNullException(nameof(other));
}
}
C#
Filtros de Excepcion
try
{
…
}
catch (ConfigurationException e)
{
}
finally
{
}
C#
Filtros de Excepcion
try
{
…
}
catch (ConfigurationException e) if (e.IsSevere)
{
}
finally
{
}
C#
Await en catch y finally
try
{
…
}
catch (ConfigurationException e) if (e.IsSevere)
{
await LogAsync(e);
}
finally
{
await CloseAsync();
}
C#
https://github.com/dotnet/roslyn
https://github.com/dotnet/roslyn/wiki/Langu
ages-features-in-C%23-6-and-VB-14
Learn more at …
C#

More Related Content

What's hot (20)

PDF
Writeup ctf online idsecconf 2017
idsecconf
 
PDF
Codigo en java pdf
DUBAN CASTRO
 
PDF
Bai tap tham khao CSPE
mrcoffee282
 
DOCX
Import java
wildled
 
RTF
Ejercicio8
jbersosa
 
DOCX
Vatesh
vatesh
 
DOCX
Sine prog
ishan111
 
TXT
Rectangulo class
Andres Acurio
 
PDF
Programación funcional en Haskell
Roberto Bonvallet
 
TXT
Los fantastico
Brenda Jazmin
 
DOC
Cg lab cse-vii
sajjan93
 
PDF
Функциональное реактивное программирование
Dmitriy Kiriyenko
 
PDF
Yohan jacobi gaussseidel_analisis
Yohan Sidik
 
PDF
Javascript i wydajność - czy to się spina?
Michał Kostrzyński
 
DOCX
Nova microsoft word document
Saša Ličina
 
PDF
デバッグ戦略
Masahiro Wakame
 
PDF
Looping
Thryo
 
TXT
Python codigo graficas
Brayan Kalaka
 
DOCX
Ejercicios c#
marthaleo36
 
Writeup ctf online idsecconf 2017
idsecconf
 
Codigo en java pdf
DUBAN CASTRO
 
Bai tap tham khao CSPE
mrcoffee282
 
Import java
wildled
 
Ejercicio8
jbersosa
 
Vatesh
vatesh
 
Sine prog
ishan111
 
Rectangulo class
Andres Acurio
 
Programación funcional en Haskell
Roberto Bonvallet
 
Los fantastico
Brenda Jazmin
 
Cg lab cse-vii
sajjan93
 
Функциональное реактивное программирование
Dmitriy Kiriyenko
 
Yohan jacobi gaussseidel_analisis
Yohan Sidik
 
Javascript i wydajność - czy to się spina?
Michał Kostrzyński
 
Nova microsoft word document
Saša Ličina
 
デバッグ戦略
Masahiro Wakame
 
Looping
Thryo
 
Python codigo graficas
Brayan Kalaka
 
Ejercicios c#
marthaleo36
 

Viewers also liked (17)

PPTX
Pitch para startups
Rodolfo Garcia
 
PPTX
потребители и ниша 2
Тайлаков Жанболат
 
PPT
STAV 2013 Powerful Apps for Powerful Learning
craff
 
PDF
L'algoritmo di Twitter e il mondo delle news 03102015
Andrea Boscaro
 
PPTX
The ombre` of modular kitchen
kitchenette1
 
DOCX
Asig 1 an
Erick Gil
 
PPTX
CMP Asamblea Octubre 2013 - Presentacion
comunicacionescmp
 
PDF
Motorola MTP850EX Ormen Lange
Nina Skaalvik
 
DOC
Ankita_Profile
Ankita Jena
 
PPT
Secuencia de operaciones portuarias
Damián Solís
 
PDF
Slipped capital femoral epiphysis
Fahad AlHulaibi
 
PDF
Cuadernos prácticos 1: Las reuniones
Fundación Esplai
 
PPTX
Developmental dysplasia of hip
Arshad Shaikh
 
PPSX
Morfología o tipos de palabras en español
AJuani ACruz Lengua
 
PPTX
Business Quiz Finals
Quest-SGGSCC
 
PPTX
Initial ideas finished
twbsMediaGroup5
 
PPTX
A2 assignment 2 digipak research copy
twbsMediaGroup5
 
Pitch para startups
Rodolfo Garcia
 
потребители и ниша 2
Тайлаков Жанболат
 
STAV 2013 Powerful Apps for Powerful Learning
craff
 
L'algoritmo di Twitter e il mondo delle news 03102015
Andrea Boscaro
 
The ombre` of modular kitchen
kitchenette1
 
Asig 1 an
Erick Gil
 
CMP Asamblea Octubre 2013 - Presentacion
comunicacionescmp
 
Motorola MTP850EX Ormen Lange
Nina Skaalvik
 
Ankita_Profile
Ankita Jena
 
Secuencia de operaciones portuarias
Damián Solís
 
Slipped capital femoral epiphysis
Fahad AlHulaibi
 
Cuadernos prácticos 1: Las reuniones
Fundación Esplai
 
Developmental dysplasia of hip
Arshad Shaikh
 
Morfología o tipos de palabras en español
AJuani ACruz Lengua
 
Business Quiz Finals
Quest-SGGSCC
 
Initial ideas finished
twbsMediaGroup5
 
A2 assignment 2 digipak research copy
twbsMediaGroup5
 
Ad

More from Ricardo González (20)

PPTX
20190506_Industria 4.0 La nube como habilitador de capacidades.pptx
Ricardo González
 
PPTX
20190615_Global Azure You build it you run it-v2_es.pptx
Ricardo González
 
PPTX
20210420_AI en la realidad del sector Fintech.pptx
Ricardo González
 
PPTX
20190520 Cloud Experience - La nube como Habilitador para la innovación.pptx
Ricardo González
 
PPTX
20190812_Modernizing-your-application-with-containers-and-serverless-SPA_ok.pptx
Ricardo González
 
PPTX
20191112_Fintalent_Democratizacion de IA.pptx
Ricardo González
 
PPTX
20161024 CFC Keynote - Transformation enablement
Ricardo González
 
PPTX
20191016_Ambientes Efímeros con IaC y DevOps.pptx
Ricardo González
 
PPTX
20240806 Well-Architected y Gobierno de Nube: Habilitadores para la Innovació...
Ricardo González
 
PPTX
202408 DevOps y DevSecOps en la Nube: Mejores Prácticas desde el Primer Día
Ricardo González
 
PDF
20240626_Por que modernizar mis aplicaciones en la nube.pdf
Ricardo González
 
PPTX
20230812 -AWS Community Day Colombia - ¿Que diablos es el Gobierno de Nube_.pptx
Ricardo González
 
PDF
20230511 Seguridad en la nube para Startups: Aprovecha las herramientas de AWS
Ricardo González
 
PDF
20230524_Tendencias en Modernizacion , innovacion y transformacion en la nube
Ricardo González
 
PPTX
20190427 arquitectura de microservicios con contenedores
Ricardo González
 
PPTX
20180520 expertslive ai_and_machine_learning_demistified
Ricardo González
 
PPTX
20180616 r gonzalez_from once per month to multiple times a day b
Ricardo González
 
PPTX
20180421 gab azure_ai_services
Ricardo González
 
PPTX
Blockchain - Desmitificacion
Ricardo González
 
PPTX
20180912 intro toazure
Ricardo González
 
20190506_Industria 4.0 La nube como habilitador de capacidades.pptx
Ricardo González
 
20190615_Global Azure You build it you run it-v2_es.pptx
Ricardo González
 
20210420_AI en la realidad del sector Fintech.pptx
Ricardo González
 
20190520 Cloud Experience - La nube como Habilitador para la innovación.pptx
Ricardo González
 
20190812_Modernizing-your-application-with-containers-and-serverless-SPA_ok.pptx
Ricardo González
 
20191112_Fintalent_Democratizacion de IA.pptx
Ricardo González
 
20161024 CFC Keynote - Transformation enablement
Ricardo González
 
20191016_Ambientes Efímeros con IaC y DevOps.pptx
Ricardo González
 
20240806 Well-Architected y Gobierno de Nube: Habilitadores para la Innovació...
Ricardo González
 
202408 DevOps y DevSecOps en la Nube: Mejores Prácticas desde el Primer Día
Ricardo González
 
20240626_Por que modernizar mis aplicaciones en la nube.pdf
Ricardo González
 
20230812 -AWS Community Day Colombia - ¿Que diablos es el Gobierno de Nube_.pptx
Ricardo González
 
20230511 Seguridad en la nube para Startups: Aprovecha las herramientas de AWS
Ricardo González
 
20230524_Tendencias en Modernizacion , innovacion y transformacion en la nube
Ricardo González
 
20190427 arquitectura de microservicios con contenedores
Ricardo González
 
20180520 expertslive ai_and_machine_learning_demistified
Ricardo González
 
20180616 r gonzalez_from once per month to multiple times a day b
Ricardo González
 
20180421 gab azure_ai_services
Ricardo González
 
Blockchain - Desmitificacion
Ricardo González
 
20180912 intro toazure
Ricardo González
 
Ad

20150415 csharp6.0

  • 1. C# C# 6.0 Ricardo Gonzalez Vargas Microsoft Regional Director - Bogota CEO – Androcial / WomyAds.com Sénior IT Architecture & SD Consultant http://about.me/ricardo.gonzalez
  • 3. C# Agenda • Evolución de C# • C# 6.0 = C# + Roslyn • Nuevas características • Ejemplos
  • 4. C# Evolución de C# C# 1.0 / Managed Code C# 2.0 / Generics C# 3.0 / LINQ C# 4.0 / Dynamic Programming C# 5.0 / Async Programming – Windows Runtime C# 6.0 / Compiler Platform
  • 5. C# C# 6.0 y Roslyn • Reimplementacion del compilador del lenguaje, escrito en el mismo lenguaje • Expone APIs para diferentes niveles de abstracción del proceso de compilación • Permite, análisis, diagnostico, manipulación y generación del código basado en los servicios de lenguaje
  • 6. C# Filosofia de diseno  No hay conceptos muy cambiantes  Muchas funcionalidades pequeñas  Enfocado en hacer mas limpio el código
  • 7. C# Propiedades automaticas de solo lectura 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); } }
  • 8. C# Propiedades automaticas de solo lectura 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); } }
  • 9. C# Propiedades automaticas de solo lectura 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. C# Inicializadores para propiedades automaticas 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); } }
  • 11. C# Uso de clases estaticas 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); } }
  • 12. C# Uso de clases estaticas 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); } }
  • 13. C# Uso de clases estaticas using static 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); } }
  • 14. C# Interpolación de cadenas 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); } }
  • 15. C# Interpolacion de cadenas 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})"; } }
  • 16. C# Metodos con expresiones como cuerpo 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})"; } }
  • 17. C# Metodos con expresiones como cuerpo 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})"
  • 18. C# Metodos con expresiones como cuerpo 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})"; }
  • 19. C# Propiedades con expresiones como cuerpo 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})"; }
  • 20. C# Propiedades con expresiones como cuerpo 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})"; }
  • 21. C# Propiedades con expresiones como cuerpo 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})"; }
  • 22. C# Inicializadores de Indices 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; } }
  • 23. C# Inicializadores de Indices public class Point { public int X { get; } public int Y { get; } … public JObject ToJson() { var result = new JObject() { ["x"] = X, ["y"] = Y }; return result; } }
  • 24. C# Inicializadores de Indices public class Point { public int X { get; } public int Y { get; } … public JObject ToJson() { return new JObject() { ["x"] = X, ["y"] = Y }; } }
  • 25. C# Inicializadores de Indices public class Point { public int X { get; } public int Y { get; } … public JObject ToJson() => new JObject() { ["x"] = X, ["y"] = Y }; }
  • 26. C# Operadores condicionados con null 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; }
  • 27. C# Operadores condicionados con null 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. C# Operadores condicionados con null 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; } ?.
  • 29. C# Operadores condicionados con null 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; }
  • 30. C# Operadores condicionados con null 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; }
  • 31. C# Operadores condicionados con null OnChanged(this, args);
  • 32. C# Operadores condicionados con null if (OnChanged != null) { OnChanged(this, args); }
  • 33. C# Operadores condicionados con null { var onChanged = OnChanged; if (onChanged != null) { onChanged(this, args); } }
  • 34. C# Operadores condicionados con null OnChanged?.Invoke(this, args);
  • 35. C# Operador nameOf public Point Add(Point point) { if (point == null) { throw new ArgumentNullException("point"); } }
  • 36. C# Operador nameOf public Point Add(Point other) { if (other == null) { throw new ArgumentNullException("point"); } }
  • 37. C# Operador nameOf public Point Add(Point point) { if (point == null) { throw new ArgumentNullException(nameof(point)); } }
  • 38. C# Operador nameOf public Point Add(Point other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } }
  • 39. C# Filtros de Excepcion try { … } catch (ConfigurationException e) { } finally { }
  • 40. C# Filtros de Excepcion try { … } catch (ConfigurationException e) if (e.IsSevere) { } finally { }
  • 41. C# Await en catch y finally try { … } catch (ConfigurationException e) if (e.IsSevere) { await LogAsync(e); } finally { await CloseAsync(); }
  • 43. C#