SlideShare a Scribd company logo
https://github.com/marcoparenzan/CSharpDay2015https://github.com/marcoparenzan/CSharpDay2015
DotNetLombardia
Milano Fiori, Italy
Slides from:
http://www.slideshare.net/fekberg1/c-60-what-c-is-being-updated-42437422 (Filip Ekberg)
http://www.slideshare.net/BlackRabbitCoder/little-wonders-5747749 (James Michael Hare)
http://downloads.academy.telerik.com/svn/seminars/2014-10-CSharp-6-and-Roslyn/What-is-New-in-CSharp-6.0.pptx (Telerik Academy)
 www.slideshare.net/marco.parenzan
 www.github.com/marcoparenzan
 marco [dot] parenzan [at] 1nn0va [dot] it
 www.1nnova.it
 @marco_parenzan
Formazione ,Divulgazione e Consulenza con 1nn0va
Microsoft MVP 2015 for Microsoft Azure
Cloud Architect, NET developer
Loves Functional Programming, Html5 Game Programming and Internet of Things AZURE
COMMUNITY
BOOTCAMP 2015
IoT Day - 08/05/2015
@1nn0va
#microservicesconf2015
9 Maggio 2015
var code = File.ReadAllText("Code.cs");
var tree = SyntaxFactory.ParseSyntaxTree(code);
var localDeclarationNodes =
tree.GetRoot()
.DescendantNodes()
.OfType<LocalDeclarationStatementSyntax>();
var tokens = node.ChildTokens();
var token = tokens.First();
token.Value;
var options = new
CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary);
var reference = new
MetadataFileReference(typeof(object).Assembly.Location);
var compilation = CSharpCompilation.Create("Test")
.WithOptions(options)
.AddSyntaxTrees(tree)
.AddReferences(reference);
var comp = CreateCompilation(tree, options, reference);
var model = comp.GetSemanticModel(tree);
var localDeclarationNodes = tree.GetRoot()
.DescendantNodes()
.OfType<LocalDeclarationStatementSyntax>();
foreach (var node in localDeclarationNodes)
{
var info = model.GetTypeInfo(node.Declaration.Type);
Console.WriteLine("{0} {1}", info.Type, node.Declaration);
}
using (var memory = new MemoryStream())
{
compilation.Emit(memory);
var assembly = Assembly.Load(memory.GetBuffer());
var type = assembly.GetType("NameOfType");
var instance = Activator.CreateInstance(type);
}
https://github.com/dotnet/roslyn/issues/2136
#347
#206
#206
#227
#114 #261
#3910
https://github.com/marcoparenzan/CSharpDay2015https://github.com/marcoparenzan/CSharpDay2015
DotNetLombardia
Milano Fiori, Italy
class Person
{
public string Name { get; set; }
}
class Person
{
public string Name { get; } = "Anonymous";
}
= "Anonymous";
class Person
{
public string Name { get; }
public Person()
{
Name = "Filip";
}
}
class Person
{
private readonly string <Name>k__BackingField = "Filip";
public string Name
{
get
{
return this.<Name>k__BackingField;
}
}
}
struct Point
{
public int X { get; }
public int Y { get; }
}
Read Only!
public Point()
{
X = 100;
Y = 100;
}
Read Only!
struct Point
{
private readonly int <X>k__BackingField;
private readonly int <Y>k__BackingField;
public int X
{
get
{
return this.<X>k__BackingField;
}
}
public int Y
{
get
{
return this.<Y>k__BackingField;
}
}
public Point()
{
this.<X>k__BackingField = 100;
this.<Y>k__BackingField = 100;
}
}
Read Only!
struct Point
{
public int X { get; }
public int Y { get; }
public Point(int x, int y)
{
X = x;
Y = y;
}
public Point() : this(100, 100)
{
}
}
class Program
{
static void Main(string[] args)
{
var angle = 90d;
Console.WriteLine(Math.Sin(angle));
}
}
using System.Console;
using System.Math;
class Program
{
static void Main(string[] args)
{
var angle = 90d;
WriteLine(Sin(angle));
}
}
using System.Console;
using System.Linq.Enumerable;
class Program
{
static void Main(string[] args)
{
foreach (var i in Range(0, 10))
{
WriteLine(i);
}
}
}
var people = new Dictionary<string, Person>
{
["Filip"] = new Person()
};
var answers = new Dictionary<int, string>
{
[42] = "the answer to life the universe and everything"
};
public async Task DownloadAsync()
{
}
try
{ }
catch
{
await Task.Delay(2000);
}
finally
{
await Task.Delay(2000);
}
try
{
throw new CustomException { Severity = 100 };
}
catch (CustomException ex) if (ex.Severity > 50)
{
Console.WriteLine("*BING BING* WARNING *BING BING*");
}
catch (CustomException ex)
{
Console.WriteLine("Whooops!");
}
class Person
{
public string Name { get; set; }
public Address Address { get; set; }
}
Console.WriteLine(filip.Address.AddressLine1);
var filip = new Person
{
Name = "Filip"
};
class Address
{
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
}
class Person
{
public string Name { get; set; }
public Address Address { get; set; }
}
Console.WriteLine(filip.Address.AddressLine1);
var filip = new Person
{
Name = "Filip"
};
class Address
{
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
}
class Person
{
public string Name { get; set; }
public Address Address { get; set; }
}
Console.WriteLine(filip.Address.AddressLine1);Console.WriteLine(filip.Address == null ? "No Address" : filip.Address.AddressLine1);
var filip = new Person
{
Name = "Filip"
};
class Address
{
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
}
class Person
{
public string Name { get; set; }
public Address Address { get; set; }
}
Console.WriteLine(filip.Address.AddressLine1);Console.WriteLine(filip.Address == null ? "No Address" : filip.Address.AddressLine1);
Console.WriteLine(filip?.Address?.AddressLine1 ?? "No Address");
var filip = new Person
{
Name = "Filip"
};
class Address
{
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
}
var people = new[]
{
new Person(),
null
};
WriteLine(people[0]?.Name);
WriteLine(people[1]?.Name);
Person[] people = null;
WriteLine(people?[0]?.Name);
Person[] people = null;
Console.WriteLine(
(people != null) ?
((people[0] == null) ? null : people[0].Name)
: null
);
class Rectangle
{
public double Width { get; set; }
public double Height { get; set; }
public double Area => Width * Height;
}
class Rectangle
{
public double Width { get; set; }
public double Height { get; set; }
public override string ToString() =>
$"My Width is {Width} and my Height is {Height}";
}
public override string ToString() =>
$"My Width is {Width} and my Height is {Height}";
public override string ToString() =>
$”My Width is {Width} and my Height is {Height}";
public override string ToString()
{
object[] args = new object[] { this.Width, this.Height };
return string.Format("My Width is {0} and my Height is {1}", args);
}
int age = 28;
var result = $"Hello there, I'm {age : D5} years old!";
WriteLine(result);
int num = 28;
object[] objArray1 = new object[] { num };
Console.WriteLine(string.Format("Hello there, I'm {0:D5} years old!", objArray1));
static void Main(string[] args)
{
WriteLine($"Parameter name is: {nameof(args)}");
}
public double CalculateArea(int width, int height)
{
if (width <= 0)
{
throw new ArgumentException($"Parameter {nameof(width)} cannot be less than 0");
}
return width * height;
}

More Related Content

Viewers also liked

Excel Gratuito - Le Funzioni più Utili di Excel
Excel Gratuito - Le Funzioni più Utili di ExcelExcel Gratuito - Le Funzioni più Utili di Excel
Excel Gratuito - Le Funzioni più Utili di ExcelMatteo Olla
 
Corso Excel Gratis - Tutorial Excel su CorsoExcel.it
Corso Excel Gratis - Tutorial Excel su CorsoExcel.itCorso Excel Gratis - Tutorial Excel su CorsoExcel.it
Corso Excel Gratis - Tutorial Excel su CorsoExcel.itcorso_excel
 
Introduction to Azure Functions
Introduction to Azure FunctionsIntroduction to Azure Functions
Introduction to Azure FunctionsMarco Parenzan
 
C# 6.0 - What?! C# is being updated?
C# 6.0 - What?! C# is being updated?C# 6.0 - What?! C# is being updated?
C# 6.0 - What?! C# is being updated?Filip Ekberg
 
Comparison of Programming Platforms
Comparison of Programming PlatformsComparison of Programming Platforms
Comparison of Programming PlatformsAnup Hariharan Nair
 
What's new with Azure Sql Database
What's new with Azure Sql DatabaseWhat's new with Azure Sql Database
What's new with Azure Sql DatabaseMarco Parenzan
 
MS EXCEL PPT PRESENTATION
MS EXCEL PPT PRESENTATIONMS EXCEL PPT PRESENTATION
MS EXCEL PPT PRESENTATIONMridul Bansal
 

Viewers also liked (9)

Informatica Base Excel
Informatica Base   ExcelInformatica Base   Excel
Informatica Base Excel
 
Excel Gratuito - Le Funzioni più Utili di Excel
Excel Gratuito - Le Funzioni più Utili di ExcelExcel Gratuito - Le Funzioni più Utili di Excel
Excel Gratuito - Le Funzioni più Utili di Excel
 
Corso Excel Gratis - Tutorial Excel su CorsoExcel.it
Corso Excel Gratis - Tutorial Excel su CorsoExcel.itCorso Excel Gratis - Tutorial Excel su CorsoExcel.it
Corso Excel Gratis - Tutorial Excel su CorsoExcel.it
 
Introduction to Azure Functions
Introduction to Azure FunctionsIntroduction to Azure Functions
Introduction to Azure Functions
 
Corso di Excel avanzato
Corso di Excel avanzatoCorso di Excel avanzato
Corso di Excel avanzato
 
C# 6.0 - What?! C# is being updated?
C# 6.0 - What?! C# is being updated?C# 6.0 - What?! C# is being updated?
C# 6.0 - What?! C# is being updated?
 
Comparison of Programming Platforms
Comparison of Programming PlatformsComparison of Programming Platforms
Comparison of Programming Platforms
 
What's new with Azure Sql Database
What's new with Azure Sql DatabaseWhat's new with Azure Sql Database
What's new with Azure Sql Database
 
MS EXCEL PPT PRESENTATION
MS EXCEL PPT PRESENTATIONMS EXCEL PPT PRESENTATION
MS EXCEL PPT PRESENTATION
 

Similar to What's new in C# 6.0

TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionHans Höchtl
 
iOSNeXT.ro - 10 reasons you'll love Swift - Paul Ardeleanu
iOSNeXT.ro - 10 reasons you'll love Swift - Paul ArdeleanuiOSNeXT.ro - 10 reasons you'll love Swift - Paul Ardeleanu
iOSNeXT.ro - 10 reasons you'll love Swift - Paul ArdeleanuPaul Ardeleanu
 
Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...
Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...
Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...Naresha K
 
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...Phil Calçado
 
The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 175 of 180
The Ring programming language version 1.5.1 book - Part 175 of 180 The Ring programming language version 1.5.1 book - Part 175 of 180
The Ring programming language version 1.5.1 book - Part 175 of 180 Mahmoud Samir Fayed
 
Effective Java with Groovy - How Language can Influence Good Practices
Effective Java with Groovy - How Language can Influence Good PracticesEffective Java with Groovy - How Language can Influence Good Practices
Effective Java with Groovy - How Language can Influence Good PracticesNaresha K
 
Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»SpbDotNet Community
 
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...Naresha K
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better JavaThomas Kaiser
 
Effective C#
Effective C#Effective C#
Effective C#lantoli
 
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019David Wengier
 
Design Pattern Observations
Design Pattern ObservationsDesign Pattern Observations
Design Pattern ObservationsDmitri Nesteruk
 
C# Starter L02-Classes and Objects
C# Starter L02-Classes and ObjectsC# Starter L02-Classes and Objects
C# Starter L02-Classes and ObjectsMohammad Shaker
 
The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.10 book - Part 22 of 212The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.10 book - Part 22 of 212Mahmoud Samir Fayed
 

Similar to What's new in C# 6.0 (20)

C# Is The Future
C# Is The FutureC# Is The Future
C# Is The Future
 
Dotnet 18
Dotnet 18Dotnet 18
Dotnet 18
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
iOSNeXT.ro - 10 reasons you'll love Swift - Paul Ardeleanu
iOSNeXT.ro - 10 reasons you'll love Swift - Paul ArdeleanuiOSNeXT.ro - 10 reasons you'll love Swift - Paul Ardeleanu
iOSNeXT.ro - 10 reasons you'll love Swift - Paul Ardeleanu
 
Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...
Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...
Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...
 
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
(ThoughtWorks Away Day 2009) one or two things you may not know about typesys...
 
The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210The Ring programming language version 1.9 book - Part 99 of 210
The Ring programming language version 1.9 book - Part 99 of 210
 
The Ring programming language version 1.5.1 book - Part 175 of 180
The Ring programming language version 1.5.1 book - Part 175 of 180 The Ring programming language version 1.5.1 book - Part 175 of 180
The Ring programming language version 1.5.1 book - Part 175 of 180
 
Effective Java with Groovy - How Language can Influence Good Practices
Effective Java with Groovy - How Language can Influence Good PracticesEffective Java with Groovy - How Language can Influence Good Practices
Effective Java with Groovy - How Language can Influence Good Practices
 
Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»
 
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better Java
 
Effective C#
Effective C#Effective C#
Effective C#
 
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
 
Design Pattern Observations
Design Pattern ObservationsDesign Pattern Observations
Design Pattern Observations
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
C# Starter L02-Classes and Objects
C# Starter L02-Classes and ObjectsC# Starter L02-Classes and Objects
C# Starter L02-Classes and Objects
 
DDDesign Challenges
DDDesign ChallengesDDDesign Challenges
DDDesign Challenges
 
The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.10 book - Part 22 of 212The Ring programming language version 1.10 book - Part 22 of 212
The Ring programming language version 1.10 book - Part 22 of 212
 
Initial Java Core Concept
Initial Java Core ConceptInitial Java Core Concept
Initial Java Core Concept
 

More from Marco Parenzan

Azure IoT Central per lo SCADA engineer
Azure IoT Central per lo SCADA engineerAzure IoT Central per lo SCADA engineer
Azure IoT Central per lo SCADA engineerMarco Parenzan
 
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptxStatic abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptxMarco Parenzan
 
Azure Synapse Analytics for your IoT Solutions
Azure Synapse Analytics for your IoT SolutionsAzure Synapse Analytics for your IoT Solutions
Azure Synapse Analytics for your IoT SolutionsMarco Parenzan
 
Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central Marco Parenzan
 
Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT CentralPower BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT CentralMarco Parenzan
 
Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT CentralPower BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT CentralMarco Parenzan
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .netMarco Parenzan
 
Math with .NET for you and Azure
Math with .NET for you and AzureMath with .NET for you and Azure
Math with .NET for you and AzureMarco Parenzan
 
Power BI data flow and Azure IoT Central
Power BI data flow and Azure IoT CentralPower BI data flow and Azure IoT Central
Power BI data flow and Azure IoT CentralMarco Parenzan
 
.net for fun: write a Christmas videogame
.net for fun: write a Christmas videogame.net for fun: write a Christmas videogame
.net for fun: write a Christmas videogameMarco Parenzan
 
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...Marco Parenzan
 
Anomaly Detection with Azure and .NET
Anomaly Detection with Azure and .NETAnomaly Detection with Azure and .NET
Anomaly Detection with Azure and .NETMarco Parenzan
 
Deploy Microsoft Azure Data Solutions
Deploy Microsoft Azure Data SolutionsDeploy Microsoft Azure Data Solutions
Deploy Microsoft Azure Data SolutionsMarco Parenzan
 
Deep Dive Time Series Anomaly Detection in Azure with dotnet
Deep Dive Time Series Anomaly Detection in Azure with dotnetDeep Dive Time Series Anomaly Detection in Azure with dotnet
Deep Dive Time Series Anomaly Detection in Azure with dotnetMarco Parenzan
 
Anomaly Detection with Azure and .net
Anomaly Detection with Azure and .netAnomaly Detection with Azure and .net
Anomaly Detection with Azure and .netMarco Parenzan
 
Code Generation for Azure with .net
Code Generation for Azure with .netCode Generation for Azure with .net
Code Generation for Azure with .netMarco Parenzan
 
Running Kafka and Spark on Raspberry PI with Azure and some .net magic
Running Kafka and Spark on Raspberry PI with Azure and some .net magicRunning Kafka and Spark on Raspberry PI with Azure and some .net magic
Running Kafka and Spark on Raspberry PI with Azure and some .net magicMarco Parenzan
 
Time Series Anomaly Detection with Azure and .NETT
Time Series Anomaly Detection with Azure and .NETTTime Series Anomaly Detection with Azure and .NETT
Time Series Anomaly Detection with Azure and .NETTMarco Parenzan
 

More from Marco Parenzan (20)

Azure IoT Central per lo SCADA engineer
Azure IoT Central per lo SCADA engineerAzure IoT Central per lo SCADA engineer
Azure IoT Central per lo SCADA engineer
 
Azure Hybrid @ Home
Azure Hybrid @ HomeAzure Hybrid @ Home
Azure Hybrid @ Home
 
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptxStatic abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
 
Azure Synapse Analytics for your IoT Solutions
Azure Synapse Analytics for your IoT SolutionsAzure Synapse Analytics for your IoT Solutions
Azure Synapse Analytics for your IoT Solutions
 
Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central
 
Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT CentralPower BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central
 
Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT CentralPower BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .net
 
Math with .NET for you and Azure
Math with .NET for you and AzureMath with .NET for you and Azure
Math with .NET for you and Azure
 
Power BI data flow and Azure IoT Central
Power BI data flow and Azure IoT CentralPower BI data flow and Azure IoT Central
Power BI data flow and Azure IoT Central
 
.net for fun: write a Christmas videogame
.net for fun: write a Christmas videogame.net for fun: write a Christmas videogame
.net for fun: write a Christmas videogame
 
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
 
Anomaly Detection with Azure and .NET
Anomaly Detection with Azure and .NETAnomaly Detection with Azure and .NET
Anomaly Detection with Azure and .NET
 
Deploy Microsoft Azure Data Solutions
Deploy Microsoft Azure Data SolutionsDeploy Microsoft Azure Data Solutions
Deploy Microsoft Azure Data Solutions
 
Deep Dive Time Series Anomaly Detection in Azure with dotnet
Deep Dive Time Series Anomaly Detection in Azure with dotnetDeep Dive Time Series Anomaly Detection in Azure with dotnet
Deep Dive Time Series Anomaly Detection in Azure with dotnet
 
Azure IoT Central
Azure IoT CentralAzure IoT Central
Azure IoT Central
 
Anomaly Detection with Azure and .net
Anomaly Detection with Azure and .netAnomaly Detection with Azure and .net
Anomaly Detection with Azure and .net
 
Code Generation for Azure with .net
Code Generation for Azure with .netCode Generation for Azure with .net
Code Generation for Azure with .net
 
Running Kafka and Spark on Raspberry PI with Azure and some .net magic
Running Kafka and Spark on Raspberry PI with Azure and some .net magicRunning Kafka and Spark on Raspberry PI with Azure and some .net magic
Running Kafka and Spark on Raspberry PI with Azure and some .net magic
 
Time Series Anomaly Detection with Azure and .NETT
Time Series Anomaly Detection with Azure and .NETTTime Series Anomaly Detection with Azure and .NETT
Time Series Anomaly Detection with Azure and .NETT
 

Recently uploaded

OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfMeon Technology
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfAMB-Review
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfkalichargn70th171
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobus
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandIES VE
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...Alluxio, Inc.
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAlluxio, Inc.
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...rajkumar669520
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAlluxio, Inc.
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion Clinic
 

Recently uploaded (20)

OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 

What's new in C# 6.0

  • 1. https://github.com/marcoparenzan/CSharpDay2015https://github.com/marcoparenzan/CSharpDay2015 DotNetLombardia Milano Fiori, Italy Slides from: http://www.slideshare.net/fekberg1/c-60-what-c-is-being-updated-42437422 (Filip Ekberg) http://www.slideshare.net/BlackRabbitCoder/little-wonders-5747749 (James Michael Hare) http://downloads.academy.telerik.com/svn/seminars/2014-10-CSharp-6-and-Roslyn/What-is-New-in-CSharp-6.0.pptx (Telerik Academy)
  • 2.  www.slideshare.net/marco.parenzan  www.github.com/marcoparenzan  marco [dot] parenzan [at] 1nn0va [dot] it  www.1nnova.it  @marco_parenzan Formazione ,Divulgazione e Consulenza con 1nn0va Microsoft MVP 2015 for Microsoft Azure Cloud Architect, NET developer Loves Functional Programming, Html5 Game Programming and Internet of Things AZURE COMMUNITY BOOTCAMP 2015 IoT Day - 08/05/2015 @1nn0va #microservicesconf2015 9 Maggio 2015
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57. var code = File.ReadAllText("Code.cs"); var tree = SyntaxFactory.ParseSyntaxTree(code);
  • 58.
  • 60. var tokens = node.ChildTokens(); var token = tokens.First(); token.Value;
  • 61.
  • 62. var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); var reference = new MetadataFileReference(typeof(object).Assembly.Location); var compilation = CSharpCompilation.Create("Test") .WithOptions(options) .AddSyntaxTrees(tree) .AddReferences(reference);
  • 63.
  • 64. var comp = CreateCompilation(tree, options, reference); var model = comp.GetSemanticModel(tree); var localDeclarationNodes = tree.GetRoot() .DescendantNodes() .OfType<LocalDeclarationStatementSyntax>(); foreach (var node in localDeclarationNodes) { var info = model.GetTypeInfo(node.Declaration.Type); Console.WriteLine("{0} {1}", info.Type, node.Declaration); }
  • 65. using (var memory = new MemoryStream()) { compilation.Emit(memory); var assembly = Assembly.Load(memory.GetBuffer()); var type = assembly.GetType("NameOfType"); var instance = Activator.CreateInstance(type); }
  • 66.
  • 67.
  • 68.
  • 70.
  • 72.
  • 73. class Person { public string Name { get; set; } } class Person { public string Name { get; } = "Anonymous"; } = "Anonymous";
  • 74. class Person { public string Name { get; } public Person() { Name = "Filip"; } }
  • 75. class Person { private readonly string <Name>k__BackingField = "Filip"; public string Name { get { return this.<Name>k__BackingField; } } }
  • 76.
  • 77. struct Point { public int X { get; } public int Y { get; } } Read Only! public Point() { X = 100; Y = 100; }
  • 78. Read Only! struct Point { private readonly int <X>k__BackingField; private readonly int <Y>k__BackingField; public int X { get { return this.<X>k__BackingField; } } public int Y { get { return this.<Y>k__BackingField; } } public Point() { this.<X>k__BackingField = 100; this.<Y>k__BackingField = 100; } }
  • 79. Read Only! struct Point { public int X { get; } public int Y { get; } public Point(int x, int y) { X = x; Y = y; } public Point() : this(100, 100) { } }
  • 80.
  • 81. class Program { static void Main(string[] args) { var angle = 90d; Console.WriteLine(Math.Sin(angle)); } }
  • 82. using System.Console; using System.Math; class Program { static void Main(string[] args) { var angle = 90d; WriteLine(Sin(angle)); } }
  • 83. using System.Console; using System.Linq.Enumerable; class Program { static void Main(string[] args) { foreach (var i in Range(0, 10)) { WriteLine(i); } } }
  • 84.
  • 85. var people = new Dictionary<string, Person> { ["Filip"] = new Person() }; var answers = new Dictionary<int, string> { [42] = "the answer to life the universe and everything" };
  • 86.
  • 87. public async Task DownloadAsync() { } try { } catch { await Task.Delay(2000); } finally { await Task.Delay(2000); }
  • 88.
  • 89. try { throw new CustomException { Severity = 100 }; } catch (CustomException ex) if (ex.Severity > 50) { Console.WriteLine("*BING BING* WARNING *BING BING*"); } catch (CustomException ex) { Console.WriteLine("Whooops!"); }
  • 90.
  • 91. class Person { public string Name { get; set; } public Address Address { get; set; } } Console.WriteLine(filip.Address.AddressLine1); var filip = new Person { Name = "Filip" }; class Address { public string AddressLine1 { get; set; } public string AddressLine2 { get; set; } }
  • 92. class Person { public string Name { get; set; } public Address Address { get; set; } } Console.WriteLine(filip.Address.AddressLine1); var filip = new Person { Name = "Filip" }; class Address { public string AddressLine1 { get; set; } public string AddressLine2 { get; set; } }
  • 93. class Person { public string Name { get; set; } public Address Address { get; set; } } Console.WriteLine(filip.Address.AddressLine1);Console.WriteLine(filip.Address == null ? "No Address" : filip.Address.AddressLine1); var filip = new Person { Name = "Filip" }; class Address { public string AddressLine1 { get; set; } public string AddressLine2 { get; set; } }
  • 94. class Person { public string Name { get; set; } public Address Address { get; set; } } Console.WriteLine(filip.Address.AddressLine1);Console.WriteLine(filip.Address == null ? "No Address" : filip.Address.AddressLine1); Console.WriteLine(filip?.Address?.AddressLine1 ?? "No Address"); var filip = new Person { Name = "Filip" }; class Address { public string AddressLine1 { get; set; } public string AddressLine2 { get; set; } }
  • 95. var people = new[] { new Person(), null }; WriteLine(people[0]?.Name); WriteLine(people[1]?.Name);
  • 96. Person[] people = null; WriteLine(people?[0]?.Name); Person[] people = null; Console.WriteLine( (people != null) ? ((people[0] == null) ? null : people[0].Name) : null );
  • 97.
  • 98. class Rectangle { public double Width { get; set; } public double Height { get; set; } public double Area => Width * Height; }
  • 99. class Rectangle { public double Width { get; set; } public double Height { get; set; } public override string ToString() => $"My Width is {Width} and my Height is {Height}"; }
  • 100.
  • 101. public override string ToString() => $"My Width is {Width} and my Height is {Height}";
  • 102. public override string ToString() => $”My Width is {Width} and my Height is {Height}"; public override string ToString() { object[] args = new object[] { this.Width, this.Height }; return string.Format("My Width is {0} and my Height is {1}", args); }
  • 103. int age = 28; var result = $"Hello there, I'm {age : D5} years old!"; WriteLine(result); int num = 28; object[] objArray1 = new object[] { num }; Console.WriteLine(string.Format("Hello there, I'm {0:D5} years old!", objArray1));
  • 104.
  • 105. static void Main(string[] args) { WriteLine($"Parameter name is: {nameof(args)}"); }
  • 106. public double CalculateArea(int width, int height) { if (width <= 0) { throw new ArgumentException($"Parameter {nameof(width)} cannot be less than 0"); } return width * height; }

Editor's Notes

  1. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  2. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  3. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*