SlideShare una empresa de Scribd logo
1 de 27
PRESENTS
Coimbatore, Tamil Nadu, India Dec 22, 2018
Brought to you by
Microsoft Connect(); 2018 - Local Event
Muralidharan Deenathayalan
Technical Architect at Quanticate
What's New in C# 8.0
Brought to you by
• C# - A quick definition
• Evolution history of C#
• New features of C# 8.0
• Demo
• How I can learn more?
• Q & A
• Reference links
2
Agenda
Brought to you by
• Nullable reference type
• Implicitly-typed new-expressions
• Ranges and indices
• Default implementations of interface members
• Recursive patterns
• Switch expressions
• Asynchronous streams
3
New features of C# 8.0
Brought to you by
4
C# - A quick definition
Brought to you by
5
Evolution history of C#
C# Version .net Fx Version Visual Studio Version Date
1.0 NET Framework 1.0 Visual Studio .NET 2002 January 2002
1.1, 1.2 .NET Framework 1.1 Visual Studio .NET 2003 April 2003
C# 2.0 .NET Framework 2.0 Visual Studio 2005 November 2005
C# 3.0 .NET Framework 3.0 Visual Studio 2008 November 2006
C# 3.5 .NET Framework 3.5 Visual Studio 2010 November 2007
C# 4.0 .NET Framework 4 Visual Studio 2010 April 2010
C# 5.0 .NET Framework 4.5 Visual Studio 2012
Visual Studio 2013
August 2012
C# 6.0 .NET Framework 4.6 Visual Studio 2015 July 2015
C# 7.0 .NET Framework 4.6.2 Visual Studio 2017 March 2017
C# 7.1 .NET Framework 4.7 Visual Studio 2017 v 15.3 August 2017
C# 7.2 .NET Framework 4.7.1 Visual Studio 2017 v 15.5 November 2017
C# 7.3 .NET Framework 4.7.2 Visual Studio 2017 v 15.7 May 2018
C# 8.0 - beta .NET Framework 4.8 Visual Studio 2019
Brought to you by
• C# variable types: Primitives and Reference types
• Primitive data type
• int, char can’t accept null
• Will have default value of 0 or depends on its data type
• To support, make is nullable like int?
• Ex : int?, char?
• Reference type
• Class etc
• Accepts null
• Default value will be null unless initialized
• Ex: string 6
Nullable reference type
Brought to you by
• Allow developers to express whether a variable, parameter or
result of a reference type is intended to be null or not.
• Provide optional warnings when such variables, parameters and
results are not used according to their intent.
7
Nullable reference type
Brought to you by
• Select C# version to 8.0 (beta)
• Add #nullable enable in the class level
8
Nullable reference type
string myname = null; //will throw warning
Console.WriteLine(myname.Length); //Will throw below warnings
• WarningCS8600 Converting null literal or possible null value to non-nullable type.
• WarningCS8602 Possible dereference of a null reference.
Brought to you by
• Select C# version to 8.0 (beta)
• Add #nullable enable in the class level
Converting to nullable as below.
9
Nullable reference type
string? myname = null; //will throw warning
Console.WriteLine(myname.Length); //Will throw below warnings
• WarningCS8602 Possible dereference of a null reference.
Brought to you by
To avoid this warning, add null check
10
Nullable reference type
string? myname = null;
if (myName != null)
Console.WriteLine(myName.Length);
else
Console.WriteLine(0);
Brought to you by
11
Implicitly-typed new-expressions
Author[] authors =
{
new Author("William", "Shakespeare"),
new Author("John", " Ford")
};
Brought to you by
12
Implicitly-typed new-expressions
Author[] authors =
{
new ("William", "Shakespeare"),
new ("John", " Ford")
};//new Syntax. No need specify the type here
Brought to you by
• Simple syntax for slicing out a part of an array
• New type is called ‘Range’
• Endpoint is exclusive
• new ^ operator, meaning "from end"
• Examples,
• 1..4
• ..1
• 1..
• 1..^2
• ^2..
13
Ranges and indices
Brought to you by
14
Ranges and indices
foreach (var name in names[1..4])
{
Console.WriteLine(name);
} // Getting 1,2 and 3rd element
Range range = 1..4;
foreach (var name in names[range])
{
Console.WriteLine(name);
}//Range variable is used
foreach (var name in names[1..^ 1])
{
Console.WriteLine(name);
}//Starting from 1st element and ending from last 1 element
Brought to you by
• Default interface methods (also known as virtual extension
methods)
• C# Addresses the diamond inheritance problem that can occur
with default interface methods by taking the most specific
override at runtime.
15
Default implementations of interface
members
Brought to you by
16
Default implementations of interface
members
interface IDefaultInterfaceMethod
{
public void DefaultMethod()
{
Console.WriteLine("I am a default method in the interface!");
}
}
class AnyClass : IDefaultInterfaceMethod
{
}
Brought to you by
17
Default implementations of interface
members
IDefaultInterfaceMethod anyClass = new AnyClass();
anyClass.DefaultMethod();
Brought to you by
18
Default implementations of interface
members
AnyClass anyClass = new AnyClass();
anyClass.DefaultMethod(); //compilation error
• AnyClass does not contain a member DefaultMethod.
• That is the proof that the inherited class does not know anything
about the default method.
Brought to you by
19
Recursive patterns
Author author = new Author("William", "Shakespeare");
switch (author.FirstName, author.LastName)
{
case (string fn, string ln):
return $"{fn} {ln} ";
case (string fn, null):
return $"{fn} ";
case (null, ln):
return $"Mr/Mrs {ln} ";
case (null, null):
return $"New author ";
}
Brought to you by
20
Switch expressions
Author author = new Author("William","Shakespeare");
return (author.FirstName, author.LastName) switch
{
(string fn, string ln) => $"{fn} {ln}",
(string fn, null) => $"{ fn}" ,
(null, ln) => $"Mr/Mrs { ln}" ,
(null, null) => $"New author "
};
Brought to you by
• Asynchrous programming techniques provide a way to improve a
program's responsiveness
• Async/Await pattern debuted in C# 5, but is limited to returning a
single scalar value.
• C# 8 adds Async Streams, which allows an async method to return
multiple values
• async Task < int > DoAnythingAsync(). The result of
DoAnythingAsync is an integer (One value).
• Because of this limitation, you cannot use this feature with yield
keyword, and you cannot use it with the async IEnumerable < int >
(which returns an async enumeration).
21
Asynchronous streams
Brought to you by
• async/awaiting feature with a yielding operator = Async Stream
• asynchronous data pull or pull based enumeration or async
sequence in F#
22
Asynchronous streams
Brought to you by
23
Demo
Brought to you by
• https://github.com/dotnet/csharplang/tree/master/proposals
• https://github.com/dotnet/roslyn/blob/master/docs/Language%
20Feature%20Status.md
• https://github.com/dotnet/roslyn
24
How I can learn more?
Brought to you by
25
Q & A
Brought to you by
• https://github.com/dotnet/coreclr/issues/21379 for
IAsyncEnumberable<T>
• https://www.infoq.com/articles/default-interface-methods-cs8
• https://www.infoq.com/articles/cs8-ranges-and-recursive-
patterns
26
References
Brought to you by
27
Keep in touch
Muralidharan Deenathayalan
Blog : www.codingfreaks.net
Github : https://github.com/muralidharand
LinkedIn : https://www.linkedin.com/in/muralidharand
Twitter : https://twitter.com/muralidharand

Más contenido relacionado

La actualidad más candente

How to Profit from Static Analysis
How to Profit from Static AnalysisHow to Profit from Static Analysis
How to Profit from Static AnalysisElena Laskavaia
 
Functions in C++ (OOP)
Functions in C++ (OOP)Functions in C++ (OOP)
Functions in C++ (OOP)Faizan Janjua
 
JavaScript fundamental data types and functions
JavaScript fundamental data types and functionsJavaScript fundamental data types and functions
JavaScript fundamental data types and functionsAndre Odendaal
 
At Last an OCL Debugger
At Last an OCL DebuggerAt Last an OCL Debugger
At Last an OCL DebuggerEdward Willink
 
Example First / A Sane Test-Driven Approach to Programming
Example First / A Sane Test-Driven Approach to ProgrammingExample First / A Sane Test-Driven Approach to Programming
Example First / A Sane Test-Driven Approach to ProgrammingJonathan Acker
 
Python-nose: A unittest-based testing framework for Python that makes writing...
Python-nose: A unittest-based testing framework for Python that makes writing...Python-nose: A unittest-based testing framework for Python that makes writing...
Python-nose: A unittest-based testing framework for Python that makes writing...Timo Stollenwerk
 
History of asynchronous in .NET
History of asynchronous in .NETHistory of asynchronous in .NET
History of asynchronous in .NETMarcin Tyborowski
 
Annotation processor and compiler plugin
Annotation processor and compiler pluginAnnotation processor and compiler plugin
Annotation processor and compiler pluginOleksandr Radchykov
 
Learning C++ - Functions in C++ 3
Learning C++ - Functions  in C++ 3Learning C++ - Functions  in C++ 3
Learning C++ - Functions in C++ 3Ali Aminian
 
Protocol-Oriented Programming in Swift
Protocol-Oriented Programming in SwiftProtocol-Oriented Programming in Swift
Protocol-Oriented Programming in SwiftOleksandr Stepanov
 
Csc1100 lecture05 ch05
Csc1100 lecture05 ch05Csc1100 lecture05 ch05
Csc1100 lecture05 ch05IIUM
 
TDD and mobile development: some forgotten techniques, illustrated with Android
TDD and mobile development: some forgotten techniques, illustrated with AndroidTDD and mobile development: some forgotten techniques, illustrated with Android
TDD and mobile development: some forgotten techniques, illustrated with AndroidCodemotion
 
Command line arguments that make you smile
Command line arguments that make you smileCommand line arguments that make you smile
Command line arguments that make you smileMartin Melin
 
Protocol in Swift
Protocol in SwiftProtocol in Swift
Protocol in SwiftYusuke Kita
 

La actualidad más candente (20)

How to Profit from Static Analysis
How to Profit from Static AnalysisHow to Profit from Static Analysis
How to Profit from Static Analysis
 
Functions in C++ (OOP)
Functions in C++ (OOP)Functions in C++ (OOP)
Functions in C++ (OOP)
 
JavaScript fundamental data types and functions
JavaScript fundamental data types and functionsJavaScript fundamental data types and functions
JavaScript fundamental data types and functions
 
At Last an OCL Debugger
At Last an OCL DebuggerAt Last an OCL Debugger
At Last an OCL Debugger
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Example First / A Sane Test-Driven Approach to Programming
Example First / A Sane Test-Driven Approach to ProgrammingExample First / A Sane Test-Driven Approach to Programming
Example First / A Sane Test-Driven Approach to Programming
 
C++ programming function
C++ programming functionC++ programming function
C++ programming function
 
Pyunit
PyunitPyunit
Pyunit
 
Python-nose: A unittest-based testing framework for Python that makes writing...
Python-nose: A unittest-based testing framework for Python that makes writing...Python-nose: A unittest-based testing framework for Python that makes writing...
Python-nose: A unittest-based testing framework for Python that makes writing...
 
History of asynchronous in .NET
History of asynchronous in .NETHistory of asynchronous in .NET
History of asynchronous in .NET
 
Annotation processor and compiler plugin
Annotation processor and compiler pluginAnnotation processor and compiler plugin
Annotation processor and compiler plugin
 
The OCLforUML Profile
The OCLforUML ProfileThe OCLforUML Profile
The OCLforUML Profile
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Learning C++ - Functions in C++ 3
Learning C++ - Functions  in C++ 3Learning C++ - Functions  in C++ 3
Learning C++ - Functions in C++ 3
 
Protocol-Oriented Programming in Swift
Protocol-Oriented Programming in SwiftProtocol-Oriented Programming in Swift
Protocol-Oriented Programming in Swift
 
Python unittest
Python unittestPython unittest
Python unittest
 
Csc1100 lecture05 ch05
Csc1100 lecture05 ch05Csc1100 lecture05 ch05
Csc1100 lecture05 ch05
 
TDD and mobile development: some forgotten techniques, illustrated with Android
TDD and mobile development: some forgotten techniques, illustrated with AndroidTDD and mobile development: some forgotten techniques, illustrated with Android
TDD and mobile development: some forgotten techniques, illustrated with Android
 
Command line arguments that make you smile
Command line arguments that make you smileCommand line arguments that make you smile
Command line arguments that make you smile
 
Protocol in Swift
Protocol in SwiftProtocol in Swift
Protocol in Swift
 

Similar a What's new in C# 8.0 (beta)

Similar a What's new in C# 8.0 (beta) (20)

What’s new in .NET
What’s new in .NETWhat’s new in .NET
What’s new in .NET
 
Developer’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming language
 
Amusing C#
Amusing C#Amusing C#
Amusing C#
 
Understanding linq
Understanding linqUnderstanding linq
Understanding linq
 
Linq intro
Linq introLinq intro
Linq intro
 
C# 7 development
C# 7 developmentC# 7 development
C# 7 development
 
Python Programming Basics for begginners
Python Programming Basics for begginnersPython Programming Basics for begginners
Python Programming Basics for begginners
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008
 
Object Oriented Programming using C++ - Part 4
Object Oriented Programming using C++ - Part 4Object Oriented Programming using C++ - Part 4
Object Oriented Programming using C++ - Part 4
 
Java gets a closure
Java gets a closureJava gets a closure
Java gets a closure
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 
Back to the Future with TypeScript
Back to the Future with TypeScriptBack to the Future with TypeScript
Back to the Future with TypeScript
 
C#unit4
C#unit4C#unit4
C#unit4
 
Roslyn and C# 6.0 New Features
Roslyn and C# 6.0 New FeaturesRoslyn and C# 6.0 New Features
Roslyn and C# 6.0 New Features
 
What's new in c# 8.0
What's new in c# 8.0What's new in c# 8.0
What's new in c# 8.0
 
What's New in Visual Studio 2008
What's New in Visual Studio 2008What's New in Visual Studio 2008
What's New in Visual Studio 2008
 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5th
 
18 dec pointers and scope resolution operator
18 dec pointers and scope resolution operator18 dec pointers and scope resolution operator
18 dec pointers and scope resolution operator
 
C#.net evolution part 2
C#.net evolution part 2C#.net evolution part 2
C#.net evolution part 2
 
Greg Demo Slides
Greg Demo SlidesGreg Demo Slides
Greg Demo Slides
 

Más de Muralidharan Deenathayalan (10)

Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
 
Alfresco 5.0 features
Alfresco 5.0 featuresAlfresco 5.0 features
Alfresco 5.0 features
 
Test drive on driven development process
Test drive on driven development processTest drive on driven development process
Test drive on driven development process
 
Map Reduce introduction
Map Reduce introductionMap Reduce introduction
Map Reduce introduction
 
Apache Hive - Introduction
Apache Hive - IntroductionApache Hive - Introduction
Apache Hive - Introduction
 
Apache cassandra
Apache cassandraApache cassandra
Apache cassandra
 
Alfresco share 4.1 to 4.2 customisation
Alfresco share 4.1 to 4.2 customisationAlfresco share 4.1 to 4.2 customisation
Alfresco share 4.1 to 4.2 customisation
 
Introduction about Alfresco webscript
Introduction about Alfresco webscriptIntroduction about Alfresco webscript
Introduction about Alfresco webscript
 
Alfresco activiti workflows
Alfresco activiti workflowsAlfresco activiti workflows
Alfresco activiti workflows
 
Alfresco content model
Alfresco content modelAlfresco content model
Alfresco content model
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Último (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

What's new in C# 8.0 (beta)

  • 1. PRESENTS Coimbatore, Tamil Nadu, India Dec 22, 2018 Brought to you by Microsoft Connect(); 2018 - Local Event Muralidharan Deenathayalan Technical Architect at Quanticate What's New in C# 8.0
  • 2. Brought to you by • C# - A quick definition • Evolution history of C# • New features of C# 8.0 • Demo • How I can learn more? • Q & A • Reference links 2 Agenda
  • 3. Brought to you by • Nullable reference type • Implicitly-typed new-expressions • Ranges and indices • Default implementations of interface members • Recursive patterns • Switch expressions • Asynchronous streams 3 New features of C# 8.0
  • 4. Brought to you by 4 C# - A quick definition
  • 5. Brought to you by 5 Evolution history of C# C# Version .net Fx Version Visual Studio Version Date 1.0 NET Framework 1.0 Visual Studio .NET 2002 January 2002 1.1, 1.2 .NET Framework 1.1 Visual Studio .NET 2003 April 2003 C# 2.0 .NET Framework 2.0 Visual Studio 2005 November 2005 C# 3.0 .NET Framework 3.0 Visual Studio 2008 November 2006 C# 3.5 .NET Framework 3.5 Visual Studio 2010 November 2007 C# 4.0 .NET Framework 4 Visual Studio 2010 April 2010 C# 5.0 .NET Framework 4.5 Visual Studio 2012 Visual Studio 2013 August 2012 C# 6.0 .NET Framework 4.6 Visual Studio 2015 July 2015 C# 7.0 .NET Framework 4.6.2 Visual Studio 2017 March 2017 C# 7.1 .NET Framework 4.7 Visual Studio 2017 v 15.3 August 2017 C# 7.2 .NET Framework 4.7.1 Visual Studio 2017 v 15.5 November 2017 C# 7.3 .NET Framework 4.7.2 Visual Studio 2017 v 15.7 May 2018 C# 8.0 - beta .NET Framework 4.8 Visual Studio 2019
  • 6. Brought to you by • C# variable types: Primitives and Reference types • Primitive data type • int, char can’t accept null • Will have default value of 0 or depends on its data type • To support, make is nullable like int? • Ex : int?, char? • Reference type • Class etc • Accepts null • Default value will be null unless initialized • Ex: string 6 Nullable reference type
  • 7. Brought to you by • Allow developers to express whether a variable, parameter or result of a reference type is intended to be null or not. • Provide optional warnings when such variables, parameters and results are not used according to their intent. 7 Nullable reference type
  • 8. Brought to you by • Select C# version to 8.0 (beta) • Add #nullable enable in the class level 8 Nullable reference type string myname = null; //will throw warning Console.WriteLine(myname.Length); //Will throw below warnings • WarningCS8600 Converting null literal or possible null value to non-nullable type. • WarningCS8602 Possible dereference of a null reference.
  • 9. Brought to you by • Select C# version to 8.0 (beta) • Add #nullable enable in the class level Converting to nullable as below. 9 Nullable reference type string? myname = null; //will throw warning Console.WriteLine(myname.Length); //Will throw below warnings • WarningCS8602 Possible dereference of a null reference.
  • 10. Brought to you by To avoid this warning, add null check 10 Nullable reference type string? myname = null; if (myName != null) Console.WriteLine(myName.Length); else Console.WriteLine(0);
  • 11. Brought to you by 11 Implicitly-typed new-expressions Author[] authors = { new Author("William", "Shakespeare"), new Author("John", " Ford") };
  • 12. Brought to you by 12 Implicitly-typed new-expressions Author[] authors = { new ("William", "Shakespeare"), new ("John", " Ford") };//new Syntax. No need specify the type here
  • 13. Brought to you by • Simple syntax for slicing out a part of an array • New type is called ‘Range’ • Endpoint is exclusive • new ^ operator, meaning "from end" • Examples, • 1..4 • ..1 • 1.. • 1..^2 • ^2.. 13 Ranges and indices
  • 14. Brought to you by 14 Ranges and indices foreach (var name in names[1..4]) { Console.WriteLine(name); } // Getting 1,2 and 3rd element Range range = 1..4; foreach (var name in names[range]) { Console.WriteLine(name); }//Range variable is used foreach (var name in names[1..^ 1]) { Console.WriteLine(name); }//Starting from 1st element and ending from last 1 element
  • 15. Brought to you by • Default interface methods (also known as virtual extension methods) • C# Addresses the diamond inheritance problem that can occur with default interface methods by taking the most specific override at runtime. 15 Default implementations of interface members
  • 16. Brought to you by 16 Default implementations of interface members interface IDefaultInterfaceMethod { public void DefaultMethod() { Console.WriteLine("I am a default method in the interface!"); } } class AnyClass : IDefaultInterfaceMethod { }
  • 17. Brought to you by 17 Default implementations of interface members IDefaultInterfaceMethod anyClass = new AnyClass(); anyClass.DefaultMethod();
  • 18. Brought to you by 18 Default implementations of interface members AnyClass anyClass = new AnyClass(); anyClass.DefaultMethod(); //compilation error • AnyClass does not contain a member DefaultMethod. • That is the proof that the inherited class does not know anything about the default method.
  • 19. Brought to you by 19 Recursive patterns Author author = new Author("William", "Shakespeare"); switch (author.FirstName, author.LastName) { case (string fn, string ln): return $"{fn} {ln} "; case (string fn, null): return $"{fn} "; case (null, ln): return $"Mr/Mrs {ln} "; case (null, null): return $"New author "; }
  • 20. Brought to you by 20 Switch expressions Author author = new Author("William","Shakespeare"); return (author.FirstName, author.LastName) switch { (string fn, string ln) => $"{fn} {ln}", (string fn, null) => $"{ fn}" , (null, ln) => $"Mr/Mrs { ln}" , (null, null) => $"New author " };
  • 21. Brought to you by • Asynchrous programming techniques provide a way to improve a program's responsiveness • Async/Await pattern debuted in C# 5, but is limited to returning a single scalar value. • C# 8 adds Async Streams, which allows an async method to return multiple values • async Task < int > DoAnythingAsync(). The result of DoAnythingAsync is an integer (One value). • Because of this limitation, you cannot use this feature with yield keyword, and you cannot use it with the async IEnumerable < int > (which returns an async enumeration). 21 Asynchronous streams
  • 22. Brought to you by • async/awaiting feature with a yielding operator = Async Stream • asynchronous data pull or pull based enumeration or async sequence in F# 22 Asynchronous streams
  • 23. Brought to you by 23 Demo
  • 24. Brought to you by • https://github.com/dotnet/csharplang/tree/master/proposals • https://github.com/dotnet/roslyn/blob/master/docs/Language% 20Feature%20Status.md • https://github.com/dotnet/roslyn 24 How I can learn more?
  • 25. Brought to you by 25 Q & A
  • 26. Brought to you by • https://github.com/dotnet/coreclr/issues/21379 for IAsyncEnumberable<T> • https://www.infoq.com/articles/default-interface-methods-cs8 • https://www.infoq.com/articles/cs8-ranges-and-recursive- patterns 26 References
  • 27. Brought to you by 27 Keep in touch Muralidharan Deenathayalan Blog : www.codingfreaks.net Github : https://github.com/muralidharand LinkedIn : https://www.linkedin.com/in/muralidharand Twitter : https://twitter.com/muralidharand