SlideShare une entreprise Scribd logo
1  sur  46
James
Montemagno
Developer Evangelist, Xamarin
james@xamarin.com motzcod.es @JamesMontemagno
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; private set; }
public string Name { get; set; }
public string Location { get; set; }
public DayOfWeek MostActiveDay
{
get { return Id == 0 ? DayOfWeek.Friday : DayOfWeek.Monday; }
}
public void Print()
{
Console.WriteLine("We printed some stuff");
}
public string DisplayName
{
get
{
return string.Format("Monkey {0} lives in {1} with Id of {2}",
Name, Location, Id);
}
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; private set; }
public string Name { get; set; }
public string Location { get; set; }
public DayOfWeek MostActiveDay
{
get { return Id == 0 ? DayOfWeek.Friday : DayOfWeek.Monday; }
}
public void Print()
{
Console.WriteLine("We printed some stuff");
}
public string DisplayName
{
get
{
return string.Format("Monkey {0} lives in {1} with Id of {2}",
Name, Location, Id);
}
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; }
public string Name { get; }
public string Location { get; set; }
public DayOfWeek MostActiveDay
{
get { return Id == 0 ? DayOfWeek.Friday : DayOfWeek.Monday; }
}
public void Print()
{
Console.WriteLine("We printed some stuff");
}
public string DisplayName
{
get
{
return string.Format("Monkey {0} lives in {1} with Id of {2}",
Name, Location, Id);
}
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; } = 0;
public string Name { get; } = "Sofia";
public string Location { get; set; } = "South America";
public DayOfWeek MostActiveDay
{
get { return Id == 0 ? DayOfWeek.Friday : DayOfWeek.Monday; }
}
public void Print()
{
Console.WriteLine("We printed some stuff");
}
public string DisplayName
{
get
{
return string.Format("Monkey {0} lives in {1} with Id of {2}",
Name, Location, Id);
}
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; } = 0;
public string Name { get; } = "Sofia";
public string Location { get; set; } = "South America";
public DayOfWeek MostActiveDay
{
get { return Id == 0 ? DayOfWeek.Friday : DayOfWeek.Monday; }
}
public void Print()
{
Console.WriteLine("We printed some stuff");
}
public string DisplayName
{
get
{
return string.Format("Monkey {0} lives in {1} with Id of {2}",
using static System.Console;
using static System.DayOfWeek;
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; } = 0;
public string Name { get; } = "Sofia";
public string Location { get; set; } = "South America";
public DayOfWeek MostActiveDay
{
get { return Id == 0 ? Friday : Monday; }
}
public void Print()
{
WriteLine("We printed some stuff");
}
public string DisplayName
{
get
{
return string.Format("Monkey {0} lives in {1} with Id of {2}",
using static System.Console;
using static System.DayOfWeek;
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; } = 0;
public string Name { get; } = "Sofia";
public string Location { get; set; } = "South America";
public DayOfWeek MostActiveDay
{
get { return Id == 0 ? Friday : Monday; }
}
public void Print()
{
WriteLine("We printed some stuff");
}
public string DisplayName
{
get
{
return string.Format("Monkey {0} lives in {1} with Id of {2}",
using static System.Console;
using static System.DayOfWeek;
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; } = 0;
public string Name { get; } = "Sofia";
public string Location { get; set; } = "South America";
public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday;
public void Print()
{
WriteLine("We printed some stuff");
}
public string DisplayName
{
get
{
return string.Format("Monkey {0} lives in {1} with Id of {2}",
Name, Location, Id);
}
using static System.Console;
using static System.DayOfWeek;
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; } = 0;
public string Name { get; } = "Sofia";
public string Location { get; set; } = "South America";
public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday;
public void Print()
{
WriteLine("We printed some stuff");
}
public string DisplayName
{
get
{
return string.Format("Monkey {0} lives in {1} with Id of {2}",
Name, Location, Id);
}
using static System.Console;
using static System.DayOfWeek;
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; } = 0;
public string Name { get; } = "Sofia";
public string Location { get; set; } = "South America";
public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday;
public void Print() => WriteLine("We printed some stuff");
public string DisplayName
{
get
{
return string.Format("Monkey {0} lives in {1} with Id of {2}",
Name, Location, Id);
}
}
}
using static System.Console;
using static System.DayOfWeek;
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; } = 0;
public string Name { get; } = "Sofia";
public string Location { get; set; } = "South America";
public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday;
public void Print() => WriteLine("We printed some stuff");
public string DisplayName
{
get
{
return string.Format("Monkey {0} lives in {1} with Id of {2}",
Name, Location, Id);
}
}
}
using static System.Console;
using static System.DayOfWeek;
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; } = 0;
public string Name { get; } = "Sofia";
public string Location { get; set; } = "South America";
public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday;
public void Print() => WriteLine("We printed some stuff");
public string DisplayName
{
get
{
return $"Monkey {Name} lives in {Location} with Id of {Id}";
}
}
}
using static System.Console;
using static System.DayOfWeek;
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; } = 0;
public string Name { get; } = "Sofia";
public string Location { get; set; } = "South America";
public DayOfWeek MostActiveDay => return Id == 0 ? Friday : Monday;
public void Print() => WriteLine("We printed some stuff");
public string DisplayName
{
get
{
return $"Monkey {Name} lives in {Location} with Id of " +
"{(Id == 0 ? "Bananas" : Id)}";
}
}
}
using static System.Console;
using static System.DayOfWeek;
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; } = 0;
public string Name { get; } = "Sofia";
public string Location { get; set; } = "South America";
public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday;
public void Print() => WriteLine("We printed some stuff");
public string DisplayName =>
$"Monkey {Name} lives in {Location} with Id of " +
"{(Id == 0 ? "Bananas" : Id)}";
}
using static System.Console;
using static System.DayOfWeek;
public class Monkey
{
public Monkey() { }
public Monkey(int id, string name, string location)
{
Id = id; Name = name; Location = location;
}
public int Id { get; } = 0;
public string Name { get; } = "Sofia";
public string Location { get; set; } = "South America";
public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday;
public void Print() => WriteLine("We printed some stuff");
public string DisplayName =>
$"Monkey {Name} lives in {Location} with Id of " +
"{(Id == 0 ? "Bananas" : Id)}";
}
var length = 0;
if(customers != null)
length = customers.Length;
int? length = customers?.Length;
// null if customers is null
Customer first = null
if(length >0)
first = customers[0];
Customer first = customers?[0];
// null if customers is null
int length = customers?.Length ?? 0;
public void OnPropertyChanged(string name)
{
var changed = PropertyChanged;
if (changed == null)
return;
changed(this, new PropertyChangedEventArgs(name));
}
public void OnPropertyChanged(string name)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
Resource res = null;
try
{
res = await Resource.OpenAsync(…); // You could do this. …
}
catch(ResourceException e)
{
await Resource.LogAsync(res, e); // Now you can do this …
}
finally
{
if (res != null)
await res.CloseAsync(); // … and this.
}
Resource res = null;
try
{
res = await Resource.OpenAsync(…); // You could do this. …
}
catch(ResourceException e) when (e.Code == 0)
{
await Resource.LogAsync(res, e); // Now you can do this …
}
finally
{
if (res != null)
await res.CloseAsync(); // … and this.
}
Resource res = null;
try
{
res = await Resource.OpenAsync(…); // You could do this. …
}
catch(ResourceException e) when (myFilter(e))
{
await Resource.LogAsync(res, e); // Now you can do this …
}
finally
{
if (res != null)
await res.CloseAsync(); // … and this.
}
private static bool Log(Exception e)
{
/* log it */ ;
return false;
}
…
try
{ … }
catch (Exception e) when (Log(e))
{
}
using System.Linq;
IEnumerable<int> range2 = Enumerable.Range(4, 3);
IEnumerable<int> squares = range2.Select(x => x * x);
foreach (int num in squares)
{
Console.WriteLine(num);
}
/*
This code produces the following output:
16
25
36
*/
using static System.Console;
using static System.Linq.Enumerable;
using static System.Console;
using static System.Linq.Enumerable;
var range = Range(4, 3);
//var squares = Select(range, x => x * x); //Not in scope
var squares2 = range.Select(x => x * x);
foreach (int num in squares2)
{
WriteLine(num);
}
public static void GetMonkey(int count)
{
if(count < 0)
throw new ArgumentNullException("count");
var monkeys = GetMonkeys();
WriteLine("Name: " + monkeys[0].Name);
// prints "Name Sofia"
}
public static void GetMonkey(int count)
{
if(count < 0)
throw new ArgumentNullException(nameof(count));
var monkeys = GetMonkeys();
WriteLine(nameof(monkeys[0].Name) + ": " + monkeys[0].Name);
// prints "Name Sofia"
}
Insights.Report(exception,
new Dictionary <string, string>
{
{"Some additional info", "foobar"},
{"Name", "James"}
}
);
Insights.Report(exception,
new Dictionary <string, string>
{
["Some additional info"] = "foobar",
["Name"] = "James"
}
);
var numbers = new Dictionary<int, string> {
[7] = "seven",
[9] = "nine",
[13] = "thirteen"
};
public void Tally(IEnumerable<int> values, out int sum, out int count)
{ ... }
int s, c;
Tally(myValues, out s, out c);
Console.WriteLine($"Sum: {s}, count: {c}");
public Tuple<int, int> Tally(IEnumerable<int> values)
{ ... }
var t = Tally(myValues);
Console.WriteLine($"Sum: {t.Item1}, count: {t.Item2}");
public (int sum, int count) Tally(IEnumerable<int> values)
{ ... }
var t = Tally(myValues);
Console.WriteLine($"Sum: {t.sum}, count: {t.count}");
public async Task<(int sum, int count)> TallyAsync(IEnumerable<int> values)
{ ... }
var t = await TallyAsync(myValues);
Console.WriteLine($"Sum: {t.sum}, count: {t.count}");
var t = new (int sum, int count) { sum = 0, count = 0 }; // out of the box today syntax
public (int sum, int count) Tally(IEnumerable<int> values)
{
var s = 0;
var c = 0;
foreach (var value in values)
{
s += value;
c++;
}
return (s, c); // target typed to (int sum, int count)
}
public (int sum, int count) Tally(IEnumerable<int> values)
{
var res = (sum: 0, count: 0); // infer tuple type from
//names and values
foreach (var value in values)
{
res.sum += value;
res.count++;
}
return res;
}
var v = expr as Monkey;
if (v != null)
{
// code using v
}
if (expr is Monkey v)
{
// code using v
//v.Name
}
int? x = 3;
if (x is int v)
{
// code using v
}
Type? v = x?.y?.z;
if (v.HasValue)
{
var value = v.GetValueOrDefault();
// code using value
}
if (x?.y?.z is Type value)
{
// code using value
}
public class Dog
{
public string Name { get; private set; }
public Dog(string name)
{
Name = name;
}
public void Bark() { }
}
Dog! myMandatoryDog = new Dog("Mandatory");
Dog? myNullableDog = new Dog("Nullable");
Dog myGeneralDog = new Dog("General");
Dog! mandatoryDog = null; // Compiler Error.
Dog? nullableDog = null; // OK.
http://bit.ly/csharp7-proposals
https://channel9.msdn.com/Series/ConnectOn-Demand/211
Thank you.
James
Montemagno
Developer Evangelist, Xamarin
james@xamarin.com motzcod.es @JamesMontemagno
Questions?

Contenu connexe

Tendances

Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Stephen Chin
 
Favouring Composition - The Groovy Way
Favouring Composition - The Groovy WayFavouring Composition - The Groovy Way
Favouring Composition - The Groovy WayNaresha K
 
Python 내장 함수
Python 내장 함수Python 내장 함수
Python 내장 함수용 최
 
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 examplesNebojša Vukšić
 
dotSwift 2016 : Beyond Crusty - Real-World Protocols
dotSwift 2016 : Beyond Crusty - Real-World ProtocolsdotSwift 2016 : Beyond Crusty - Real-World Protocols
dotSwift 2016 : Beyond Crusty - Real-World ProtocolsRob Napier
 
Intro programacion funcional
Intro programacion funcionalIntro programacion funcional
Intro programacion funcionalNSCoder Mexico
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackVic Metcalfe
 
Thoughts on MongoDB Analytics
Thoughts on MongoDB AnalyticsThoughts on MongoDB Analytics
Thoughts on MongoDB Analyticsrogerbodamer
 
Generics and Inference
Generics and InferenceGenerics and Inference
Generics and InferenceRichard Fox
 
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークGroovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークTsuyoshi Yamamoto
 
What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)Kerry Buckley
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2Raghu nath
 
python chapter 1
python chapter 1python chapter 1
python chapter 1Raghu nath
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. ExperienceMike Fogus
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎juzihua1102
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎anzhong70
 

Tendances (20)

Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)
 
Favouring Composition - The Groovy Way
Favouring Composition - The Groovy WayFavouring Composition - The Groovy Way
Favouring Composition - The Groovy Way
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
Benefits of Kotlin
Benefits of KotlinBenefits of Kotlin
Benefits of Kotlin
 
Python 내장 함수
Python 내장 함수Python 내장 함수
Python 내장 함수
 
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
 
dotSwift 2016 : Beyond Crusty - Real-World Protocols
dotSwift 2016 : Beyond Crusty - Real-World ProtocolsdotSwift 2016 : Beyond Crusty - Real-World Protocols
dotSwift 2016 : Beyond Crusty - Real-World Protocols
 
Intro programacion funcional
Intro programacion funcionalIntro programacion funcional
Intro programacion funcional
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: Hack
 
Thoughts on MongoDB Analytics
Thoughts on MongoDB AnalyticsThoughts on MongoDB Analytics
Thoughts on MongoDB Analytics
 
Generics and Inference
Generics and InferenceGenerics and Inference
Generics and Inference
 
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークGroovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトーク
 
What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)What I learned from Seven Languages in Seven Weeks (IPRUG)
What I learned from Seven Languages in Seven Weeks (IPRUG)
 
Python dictionaries
Python dictionariesPython dictionaries
Python dictionaries
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. Experience
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎
 
Drupal 8 database api
Drupal 8 database apiDrupal 8 database api
Drupal 8 database api
 

Similaire à What's new in C# 6?

Creating a Facebook Clone - Part XX.pdf
Creating a Facebook Clone - Part XX.pdfCreating a Facebook Clone - Part XX.pdf
Creating a Facebook Clone - Part XX.pdfShaiAlmog1
 
Realm: Building a mobile database
Realm: Building a mobile databaseRealm: Building a mobile database
Realm: Building a mobile databaseChristian Melchior
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBtdc-globalcode
 
can do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfcan do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfakshpatil4
 
TDC2016SP - Trilha .NET
TDC2016SP - Trilha .NETTDC2016SP - Trilha .NET
TDC2016SP - Trilha .NETtdc-globalcode
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Seri Moth
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodecamp Romania
 
Creating a Facebook Clone - Part X.pdf
Creating a Facebook Clone - Part X.pdfCreating a Facebook Clone - Part X.pdf
Creating a Facebook Clone - Part X.pdfShaiAlmog1
 
Best of build 2021 - C# 10 & .NET 6
Best of build 2021 -  C# 10 & .NET 6Best of build 2021 -  C# 10 & .NET 6
Best of build 2021 - C# 10 & .NET 6Moaid Hathot
 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesSimon Willison
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo....NET Conf UY
 
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
 
jSession #3 - Krzysztof Czajkowski - Lombok in Java
jSession #3 - Krzysztof Czajkowski - Lombok in JavajSession #3 - Krzysztof Czajkowski - Lombok in Java
jSession #3 - Krzysztof Czajkowski - Lombok in JavajSession
 
From java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+kFrom java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+kFabio Collini
 
Speed up the mobile development process
Speed up the mobile development processSpeed up the mobile development process
Speed up the mobile development processLeonardoSarra
 

Similaire à What's new in C# 6? (20)

Creating a Facebook Clone - Part XX.pdf
Creating a Facebook Clone - Part XX.pdfCreating a Facebook Clone - Part XX.pdf
Creating a Facebook Clone - Part XX.pdf
 
Realm: Building a mobile database
Realm: Building a mobile databaseRealm: Building a mobile database
Realm: Building a mobile database
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
 
can do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfcan do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdf
 
TDC2016SP - Trilha .NET
TDC2016SP - Trilha .NETTDC2016SP - Trilha .NET
TDC2016SP - Trilha .NET
 
Kill the DBA
Kill the DBAKill the DBA
Kill the DBA
 
Presentatie - Introductie in Groovy
Presentatie - Introductie in GroovyPresentatie - Introductie in Groovy
Presentatie - Introductie in Groovy
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
Creating a Facebook Clone - Part X.pdf
Creating a Facebook Clone - Part X.pdfCreating a Facebook Clone - Part X.pdf
Creating a Facebook Clone - Part X.pdf
 
C# 6.0
C# 6.0C# 6.0
C# 6.0
 
Best of build 2021 - C# 10 & .NET 6
Best of build 2021 -  C# 10 & .NET 6Best of build 2021 -  C# 10 & .NET 6
Best of build 2021 - C# 10 & .NET 6
 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The Libraries
 
Introduzione a C#
Introduzione a C#Introduzione a C#
Introduzione a C#
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
 
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
 
Architecure components by Paulina Szklarska
Architecure components by Paulina SzklarskaArchitecure components by Paulina Szklarska
Architecure components by Paulina Szklarska
 
jSession #3 - Krzysztof Czajkowski - Lombok in Java
jSession #3 - Krzysztof Czajkowski - Lombok in JavajSession #3 - Krzysztof Czajkowski - Lombok in Java
jSession #3 - Krzysztof Czajkowski - Lombok in Java
 
From java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+kFrom java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+k
 
Speed up the mobile development process
Speed up the mobile development processSpeed up the mobile development process
Speed up the mobile development process
 

Plus de James Montemagno

What's new and next for mobile development with .NET
What's new and next for mobile development with .NETWhat's new and next for mobile development with .NET
What's new and next for mobile development with .NETJames Montemagno
 
Taking Mobile Development Serverless with C#
Taking Mobile Development Serverless with C#Taking Mobile Development Serverless with C#
Taking Mobile Development Serverless with C#James Montemagno
 
.NET North UG - What’s new & next for Xamarin developers
.NET North UG - What’s new & next for Xamarin developers.NET North UG - What’s new & next for Xamarin developers
.NET North UG - What’s new & next for Xamarin developersJames Montemagno
 
Building Stream Deck Plugins in C#
Building Stream Deck Plugins in C#Building Stream Deck Plugins in C#
Building Stream Deck Plugins in C#James Montemagno
 
.Net Dev Summit 2020 - What's new and next for Xamarin developers
.Net Dev Summit 2020 - What's new and next for Xamarin developers.Net Dev Summit 2020 - What's new and next for Xamarin developers
.Net Dev Summit 2020 - What's new and next for Xamarin developersJames Montemagno
 
Creating Island Tracker - Xamarin, Azure Functions, Table Storage, & More
Creating Island Tracker - Xamarin, Azure Functions, Table Storage, & MoreCreating Island Tracker - Xamarin, Azure Functions, Table Storage, & More
Creating Island Tracker - Xamarin, Azure Functions, Table Storage, & MoreJames Montemagno
 
Xamarin.forms Shell + Navigation
Xamarin.forms Shell + NavigationXamarin.forms Shell + Navigation
Xamarin.forms Shell + NavigationJames Montemagno
 
Seattle Mobile .NET User Group - Nov. 13th 2019
Seattle Mobile .NET User Group - Nov. 13th 2019Seattle Mobile .NET User Group - Nov. 13th 2019
Seattle Mobile .NET User Group - Nov. 13th 2019James Montemagno
 
Expert Day - What's New, Hot, & Awesome for Xamarin Devs
Expert Day - What's New, Hot, & Awesome for Xamarin DevsExpert Day - What's New, Hot, & Awesome for Xamarin Devs
Expert Day - What's New, Hot, & Awesome for Xamarin DevsJames Montemagno
 
Oxford .NET - Go Mobile with Xamarin
Oxford .NET - Go Mobile with XamarinOxford .NET - Go Mobile with Xamarin
Oxford .NET - Go Mobile with XamarinJames Montemagno
 
Xamarin - New & Awesome + Building Xamarin.Essentials
Xamarin - New & Awesome + Building Xamarin.EssentialsXamarin - New & Awesome + Building Xamarin.Essentials
Xamarin - New & Awesome + Building Xamarin.EssentialsJames Montemagno
 
Zebra App Forum 2019 - Building iOS & Android Apps with Xamarin
Zebra App Forum 2019 - Building iOS & Android Apps with XamarinZebra App Forum 2019 - Building iOS & Android Apps with Xamarin
Zebra App Forum 2019 - Building iOS & Android Apps with XamarinJames Montemagno
 
Stunning Mobile Apps with the Xamarin Visual Design System​
Stunning Mobile Apps with the Xamarin Visual Design System​Stunning Mobile Apps with the Xamarin Visual Design System​
Stunning Mobile Apps with the Xamarin Visual Design System​James Montemagno
 
What's New, Hot, & Awesome for Xamarin Developers!
What's New, Hot, & Awesome for Xamarin Developers!What's New, Hot, & Awesome for Xamarin Developers!
What's New, Hot, & Awesome for Xamarin Developers!James Montemagno
 
Introduction to Mobile Development with Xamarin -DotNet Westide
Introduction to Mobile Development with Xamarin -DotNet WestideIntroduction to Mobile Development with Xamarin -DotNet Westide
Introduction to Mobile Development with Xamarin -DotNet WestideJames Montemagno
 
What's New in Xamarin? - Santo Domingo
What's New in Xamarin? - Santo DomingoWhat's New in Xamarin? - Santo Domingo
What's New in Xamarin? - Santo DomingoJames Montemagno
 
Xamarin: The Future of App Development
Xamarin: The Future of App DevelopmentXamarin: The Future of App Development
Xamarin: The Future of App DevelopmentJames Montemagno
 
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP AppsOptimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP AppsJames Montemagno
 
.NET Everywhere and for Everyone
.NET Everywhere and for Everyone.NET Everywhere and for Everyone
.NET Everywhere and for EveryoneJames Montemagno
 
MS Experiences 17 - Xamarin: Future of Mobile Development
MS Experiences 17 - Xamarin: Future of Mobile DevelopmentMS Experiences 17 - Xamarin: Future of Mobile Development
MS Experiences 17 - Xamarin: Future of Mobile DevelopmentJames Montemagno
 

Plus de James Montemagno (20)

What's new and next for mobile development with .NET
What's new and next for mobile development with .NETWhat's new and next for mobile development with .NET
What's new and next for mobile development with .NET
 
Taking Mobile Development Serverless with C#
Taking Mobile Development Serverless with C#Taking Mobile Development Serverless with C#
Taking Mobile Development Serverless with C#
 
.NET North UG - What’s new & next for Xamarin developers
.NET North UG - What’s new & next for Xamarin developers.NET North UG - What’s new & next for Xamarin developers
.NET North UG - What’s new & next for Xamarin developers
 
Building Stream Deck Plugins in C#
Building Stream Deck Plugins in C#Building Stream Deck Plugins in C#
Building Stream Deck Plugins in C#
 
.Net Dev Summit 2020 - What's new and next for Xamarin developers
.Net Dev Summit 2020 - What's new and next for Xamarin developers.Net Dev Summit 2020 - What's new and next for Xamarin developers
.Net Dev Summit 2020 - What's new and next for Xamarin developers
 
Creating Island Tracker - Xamarin, Azure Functions, Table Storage, & More
Creating Island Tracker - Xamarin, Azure Functions, Table Storage, & MoreCreating Island Tracker - Xamarin, Azure Functions, Table Storage, & More
Creating Island Tracker - Xamarin, Azure Functions, Table Storage, & More
 
Xamarin.forms Shell + Navigation
Xamarin.forms Shell + NavigationXamarin.forms Shell + Navigation
Xamarin.forms Shell + Navigation
 
Seattle Mobile .NET User Group - Nov. 13th 2019
Seattle Mobile .NET User Group - Nov. 13th 2019Seattle Mobile .NET User Group - Nov. 13th 2019
Seattle Mobile .NET User Group - Nov. 13th 2019
 
Expert Day - What's New, Hot, & Awesome for Xamarin Devs
Expert Day - What's New, Hot, & Awesome for Xamarin DevsExpert Day - What's New, Hot, & Awesome for Xamarin Devs
Expert Day - What's New, Hot, & Awesome for Xamarin Devs
 
Oxford .NET - Go Mobile with Xamarin
Oxford .NET - Go Mobile with XamarinOxford .NET - Go Mobile with Xamarin
Oxford .NET - Go Mobile with Xamarin
 
Xamarin - New & Awesome + Building Xamarin.Essentials
Xamarin - New & Awesome + Building Xamarin.EssentialsXamarin - New & Awesome + Building Xamarin.Essentials
Xamarin - New & Awesome + Building Xamarin.Essentials
 
Zebra App Forum 2019 - Building iOS & Android Apps with Xamarin
Zebra App Forum 2019 - Building iOS & Android Apps with XamarinZebra App Forum 2019 - Building iOS & Android Apps with Xamarin
Zebra App Forum 2019 - Building iOS & Android Apps with Xamarin
 
Stunning Mobile Apps with the Xamarin Visual Design System​
Stunning Mobile Apps with the Xamarin Visual Design System​Stunning Mobile Apps with the Xamarin Visual Design System​
Stunning Mobile Apps with the Xamarin Visual Design System​
 
What's New, Hot, & Awesome for Xamarin Developers!
What's New, Hot, & Awesome for Xamarin Developers!What's New, Hot, & Awesome for Xamarin Developers!
What's New, Hot, & Awesome for Xamarin Developers!
 
Introduction to Mobile Development with Xamarin -DotNet Westide
Introduction to Mobile Development with Xamarin -DotNet WestideIntroduction to Mobile Development with Xamarin -DotNet Westide
Introduction to Mobile Development with Xamarin -DotNet Westide
 
What's New in Xamarin? - Santo Domingo
What's New in Xamarin? - Santo DomingoWhat's New in Xamarin? - Santo Domingo
What's New in Xamarin? - Santo Domingo
 
Xamarin: The Future of App Development
Xamarin: The Future of App DevelopmentXamarin: The Future of App Development
Xamarin: The Future of App Development
 
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP AppsOptimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
 
.NET Everywhere and for Everyone
.NET Everywhere and for Everyone.NET Everywhere and for Everyone
.NET Everywhere and for Everyone
 
MS Experiences 17 - Xamarin: Future of Mobile Development
MS Experiences 17 - Xamarin: Future of Mobile DevelopmentMS Experiences 17 - Xamarin: Future of Mobile Development
MS Experiences 17 - Xamarin: Future of Mobile Development
 

Dernier

Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
The SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsThe SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsDILIPKUMARMONDAL6
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptNarmatha D
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Internet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxInternet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxVelmuruganTECE
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESNarmatha D
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 

Dernier (20)

Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
The SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teamsThe SRE Report 2024 - Great Findings for the teams
The SRE Report 2024 - Great Findings for the teams
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.ppt
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Internet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptxInternet of things -Arshdeep Bahga .pptx
Internet of things -Arshdeep Bahga .pptx
 
Industrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIESIndustrial Safety Unit-I SAFETY TERMINOLOGIES
Industrial Safety Unit-I SAFETY TERMINOLOGIES
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 

What's new in C# 6?

  • 1.
  • 3.
  • 4. public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; private set; } public string Name { get; set; } public string Location { get; set; } public DayOfWeek MostActiveDay { get { return Id == 0 ? DayOfWeek.Friday : DayOfWeek.Monday; } } public void Print() { Console.WriteLine("We printed some stuff"); } public string DisplayName { get { return string.Format("Monkey {0} lives in {1} with Id of {2}", Name, Location, Id); }
  • 5. public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; private set; } public string Name { get; set; } public string Location { get; set; } public DayOfWeek MostActiveDay { get { return Id == 0 ? DayOfWeek.Friday : DayOfWeek.Monday; } } public void Print() { Console.WriteLine("We printed some stuff"); } public string DisplayName { get { return string.Format("Monkey {0} lives in {1} with Id of {2}", Name, Location, Id); }
  • 6. public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } public string Name { get; } public string Location { get; set; } public DayOfWeek MostActiveDay { get { return Id == 0 ? DayOfWeek.Friday : DayOfWeek.Monday; } } public void Print() { Console.WriteLine("We printed some stuff"); } public string DisplayName { get { return string.Format("Monkey {0} lives in {1} with Id of {2}", Name, Location, Id); }
  • 7. public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } = 0; public string Name { get; } = "Sofia"; public string Location { get; set; } = "South America"; public DayOfWeek MostActiveDay { get { return Id == 0 ? DayOfWeek.Friday : DayOfWeek.Monday; } } public void Print() { Console.WriteLine("We printed some stuff"); } public string DisplayName { get { return string.Format("Monkey {0} lives in {1} with Id of {2}", Name, Location, Id); }
  • 8. public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } = 0; public string Name { get; } = "Sofia"; public string Location { get; set; } = "South America"; public DayOfWeek MostActiveDay { get { return Id == 0 ? DayOfWeek.Friday : DayOfWeek.Monday; } } public void Print() { Console.WriteLine("We printed some stuff"); } public string DisplayName { get { return string.Format("Monkey {0} lives in {1} with Id of {2}",
  • 9. using static System.Console; using static System.DayOfWeek; public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } = 0; public string Name { get; } = "Sofia"; public string Location { get; set; } = "South America"; public DayOfWeek MostActiveDay { get { return Id == 0 ? Friday : Monday; } } public void Print() { WriteLine("We printed some stuff"); } public string DisplayName { get { return string.Format("Monkey {0} lives in {1} with Id of {2}",
  • 10. using static System.Console; using static System.DayOfWeek; public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } = 0; public string Name { get; } = "Sofia"; public string Location { get; set; } = "South America"; public DayOfWeek MostActiveDay { get { return Id == 0 ? Friday : Monday; } } public void Print() { WriteLine("We printed some stuff"); } public string DisplayName { get { return string.Format("Monkey {0} lives in {1} with Id of {2}",
  • 11. using static System.Console; using static System.DayOfWeek; public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } = 0; public string Name { get; } = "Sofia"; public string Location { get; set; } = "South America"; public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday; public void Print() { WriteLine("We printed some stuff"); } public string DisplayName { get { return string.Format("Monkey {0} lives in {1} with Id of {2}", Name, Location, Id); }
  • 12. using static System.Console; using static System.DayOfWeek; public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } = 0; public string Name { get; } = "Sofia"; public string Location { get; set; } = "South America"; public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday; public void Print() { WriteLine("We printed some stuff"); } public string DisplayName { get { return string.Format("Monkey {0} lives in {1} with Id of {2}", Name, Location, Id); }
  • 13. using static System.Console; using static System.DayOfWeek; public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } = 0; public string Name { get; } = "Sofia"; public string Location { get; set; } = "South America"; public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday; public void Print() => WriteLine("We printed some stuff"); public string DisplayName { get { return string.Format("Monkey {0} lives in {1} with Id of {2}", Name, Location, Id); } } }
  • 14. using static System.Console; using static System.DayOfWeek; public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } = 0; public string Name { get; } = "Sofia"; public string Location { get; set; } = "South America"; public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday; public void Print() => WriteLine("We printed some stuff"); public string DisplayName { get { return string.Format("Monkey {0} lives in {1} with Id of {2}", Name, Location, Id); } } }
  • 15. using static System.Console; using static System.DayOfWeek; public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } = 0; public string Name { get; } = "Sofia"; public string Location { get; set; } = "South America"; public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday; public void Print() => WriteLine("We printed some stuff"); public string DisplayName { get { return $"Monkey {Name} lives in {Location} with Id of {Id}"; } } }
  • 16. using static System.Console; using static System.DayOfWeek; public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } = 0; public string Name { get; } = "Sofia"; public string Location { get; set; } = "South America"; public DayOfWeek MostActiveDay => return Id == 0 ? Friday : Monday; public void Print() => WriteLine("We printed some stuff"); public string DisplayName { get { return $"Monkey {Name} lives in {Location} with Id of " + "{(Id == 0 ? "Bananas" : Id)}"; } } }
  • 17. using static System.Console; using static System.DayOfWeek; public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } = 0; public string Name { get; } = "Sofia"; public string Location { get; set; } = "South America"; public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday; public void Print() => WriteLine("We printed some stuff"); public string DisplayName => $"Monkey {Name} lives in {Location} with Id of " + "{(Id == 0 ? "Bananas" : Id)}"; }
  • 18. using static System.Console; using static System.DayOfWeek; public class Monkey { public Monkey() { } public Monkey(int id, string name, string location) { Id = id; Name = name; Location = location; } public int Id { get; } = 0; public string Name { get; } = "Sofia"; public string Location { get; set; } = "South America"; public DayOfWeek MostActiveDay => Id == 0 ? Friday : Monday; public void Print() => WriteLine("We printed some stuff"); public string DisplayName => $"Monkey {Name} lives in {Location} with Id of " + "{(Id == 0 ? "Bananas" : Id)}"; }
  • 19.
  • 20. var length = 0; if(customers != null) length = customers.Length; int? length = customers?.Length; // null if customers is null Customer first = null if(length >0) first = customers[0]; Customer first = customers?[0]; // null if customers is null int length = customers?.Length ?? 0;
  • 21. public void OnPropertyChanged(string name) { var changed = PropertyChanged; if (changed == null) return; changed(this, new PropertyChangedEventArgs(name)); }
  • 22. public void OnPropertyChanged(string name) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); }
  • 23.
  • 24. Resource res = null; try { res = await Resource.OpenAsync(…); // You could do this. … } catch(ResourceException e) { await Resource.LogAsync(res, e); // Now you can do this … } finally { if (res != null) await res.CloseAsync(); // … and this. }
  • 25. Resource res = null; try { res = await Resource.OpenAsync(…); // You could do this. … } catch(ResourceException e) when (e.Code == 0) { await Resource.LogAsync(res, e); // Now you can do this … } finally { if (res != null) await res.CloseAsync(); // … and this. }
  • 26. Resource res = null; try { res = await Resource.OpenAsync(…); // You could do this. … } catch(ResourceException e) when (myFilter(e)) { await Resource.LogAsync(res, e); // Now you can do this … } finally { if (res != null) await res.CloseAsync(); // … and this. }
  • 27. private static bool Log(Exception e) { /* log it */ ; return false; } … try { … } catch (Exception e) when (Log(e)) { }
  • 28. using System.Linq; IEnumerable<int> range2 = Enumerable.Range(4, 3); IEnumerable<int> squares = range2.Select(x => x * x); foreach (int num in squares) { Console.WriteLine(num); } /* This code produces the following output: 16 25 36 */
  • 29. using static System.Console; using static System.Linq.Enumerable;
  • 30. using static System.Console; using static System.Linq.Enumerable; var range = Range(4, 3); //var squares = Select(range, x => x * x); //Not in scope var squares2 = range.Select(x => x * x); foreach (int num in squares2) { WriteLine(num); }
  • 31. public static void GetMonkey(int count) { if(count < 0) throw new ArgumentNullException("count"); var monkeys = GetMonkeys(); WriteLine("Name: " + monkeys[0].Name); // prints "Name Sofia" }
  • 32. public static void GetMonkey(int count) { if(count < 0) throw new ArgumentNullException(nameof(count)); var monkeys = GetMonkeys(); WriteLine(nameof(monkeys[0].Name) + ": " + monkeys[0].Name); // prints "Name Sofia" }
  • 33. Insights.Report(exception, new Dictionary <string, string> { {"Some additional info", "foobar"}, {"Name", "James"} } );
  • 34. Insights.Report(exception, new Dictionary <string, string> { ["Some additional info"] = "foobar", ["Name"] = "James" } );
  • 35. var numbers = new Dictionary<int, string> { [7] = "seven", [9] = "nine", [13] = "thirteen" };
  • 36.
  • 37.
  • 38. public void Tally(IEnumerable<int> values, out int sum, out int count) { ... } int s, c; Tally(myValues, out s, out c); Console.WriteLine($"Sum: {s}, count: {c}"); public Tuple<int, int> Tally(IEnumerable<int> values) { ... } var t = Tally(myValues); Console.WriteLine($"Sum: {t.Item1}, count: {t.Item2}");
  • 39. public (int sum, int count) Tally(IEnumerable<int> values) { ... } var t = Tally(myValues); Console.WriteLine($"Sum: {t.sum}, count: {t.count}"); public async Task<(int sum, int count)> TallyAsync(IEnumerable<int> values) { ... } var t = await TallyAsync(myValues); Console.WriteLine($"Sum: {t.sum}, count: {t.count}");
  • 40. var t = new (int sum, int count) { sum = 0, count = 0 }; // out of the box today syntax public (int sum, int count) Tally(IEnumerable<int> values) { var s = 0; var c = 0; foreach (var value in values) { s += value; c++; } return (s, c); // target typed to (int sum, int count) } public (int sum, int count) Tally(IEnumerable<int> values) { var res = (sum: 0, count: 0); // infer tuple type from //names and values foreach (var value in values) { res.sum += value; res.count++; } return res; }
  • 41. var v = expr as Monkey; if (v != null) { // code using v } if (expr is Monkey v) { // code using v //v.Name } int? x = 3; if (x is int v) { // code using v }
  • 42. Type? v = x?.y?.z; if (v.HasValue) { var value = v.GetValueOrDefault(); // code using value } if (x?.y?.z is Type value) { // code using value }
  • 43. public class Dog { public string Name { get; private set; } public Dog(string name) { Name = name; } public void Bark() { } } Dog! myMandatoryDog = new Dog("Mandatory"); Dog? myNullableDog = new Dog("Nullable"); Dog myGeneralDog = new Dog("General"); Dog! mandatoryDog = null; // Compiler Error. Dog? nullableDog = null; // OK.
  • 46. Thank you. James Montemagno Developer Evangelist, Xamarin james@xamarin.com motzcod.es @JamesMontemagno Questions?