SlideShare a Scribd company logo
New Features in C# 6.0
01
What to expect from this slide?
 Microsoft has announced some new keywords and behavior for C# 6.0 in Visual Studio 2015
 The features are listed as a comparison between C# 6.0 and C# 5.0
 Relevant samples are also provided to get a better understanding of the features.
02
What are new features ?
 using Static
 Auto property initializer
 Dictionary Initializer
 nameof Expression
 New way for Exception filters
 Null – Conditional Operator
 Expression–Bodied Methods
 Easily format strings – String interpolation
03
1) using static
C# 6.0 allows us to use any class that is static as a namespace. This is very useful for every developer where we need to call the static
methods from a static class
1) Convert.ToInt32()
2) Console.WriteLine()
e.g. code in C# 5.0
Console.WriteLine(“Enter First Number : “);
int num1 = Convert.ToInt32(Console.ReadLine());
How to write the same code in C# 6.0
using System.Console;
using System.Convert;
WriteLine(“Enter First Number : ”); int mum1 = ToInt32(ReadLine());
04
1) using static (cont’d)
C# 5.0 Screenshot C# 6.0 Screenshot
05
2) Auto property initializer
C# 5.0 C# 6.0
Auto property initializer is a new concept to set the value of a property during property declaration. We can set default value to
a read-only property, it means a property that has only a {get;} attribute.
06
3) Dictionary Initializer
In C# 6.0, the dictionary initialization happens in the same way but with keys as indexers which makes the code easy to read
and understandable. Here is a piece of code to show you how the new initializing feature can be used. This is almost similar to
how you access them e.g. errorCodes [1] = “Ex000001”.
Here in C# 6.0 we can initialize the Dictionary values directly by the “=” operator and in C# 5.0 we need to create an object as a
{key,value} pair and the output will be the same in both versions.
Dictionary Initialization is not a new thing in C#. It was present since C# 3.0, but in C# 6.0 Microsoft enhanced this by adding a
new ability to use the key/indexer to map with the dictionary values directly during the initialization itself.
The following code snippet shows how dictionary initializer were used prior to C# 6.0 to initialize dictionary objects with key
and values. This is still valid and you can use it as earlier.
07
3) Dictionary Initializer (cont’d)
C# 6C# 5
08
4) nameof - Expression
nameof expression will return a string literal of the name of a property or a method.
09
5) Exception filters
Exception filters allow us to specify a condition with a catch block. So the catch block is executed only if the condition is satisfied.
10
6) Null-Conditional Operator
Suppose we need to write a code to compare the objects of an employee class with null-conditional operator in C# 5.0, we will need
to write multiple lines of code using if() and else. In C# 6.0, we can rewrite the same code using ? and ?? .
The following sample code shows how to check the null value of an object in C# 6.0
11
7) Expression–Bodied Methods
C#5.0 C#6.0
An Expression–Bodied Method is a very useful way to write a function in a new way. By using the “=>“ lamda Operator in C# 6.0, we
can easily write methods with single line.
12
8) Easily format strings using String interpolation
To easily format a string value in C# 6.0 without any string.Format() method we can write a format for a string. It's a very useful and
time saving process to define multiple string values by
$“{ variable }”.
13
SOFTWARE ASSOCIATES
Software Associates “Mascot”, Zilla Bungalow Road, Nadakkavu,
Kozhikode PIN 673011, Kerala, India
Kozhikode +91 495 276 5837 | Bangalore +91 984 700 5656 | London
+44 797 340 0804
REACH OUT TO US
Ad

More Related Content

What's hot (20)

csharp repitition structures
csharp repitition structurescsharp repitition structures
csharp repitition structures
Micheal Ogundero
 
Function Pointer in C
Function Pointer in CFunction Pointer in C
Function Pointer in C
Lakshmi Sarvani Videla
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
Mehmet Emin İNAÇ
 
selection structures
selection structuresselection structures
selection structures
Micheal Ogundero
 
escape sequences and substitution markers
escape sequences and substitution markersescape sequences and substitution markers
escape sequences and substitution markers
Micheal Ogundero
 
C++ Tail Recursion Using 64-bit variables
C++ Tail Recursion Using 64-bit variablesC++ Tail Recursion Using 64-bit variables
C++ Tail Recursion Using 64-bit variables
PVS-Studio
 
Interfaces Not Required — RubyHACK 2018
Interfaces Not Required — RubyHACK 2018Interfaces Not Required — RubyHACK 2018
Interfaces Not Required — RubyHACK 2018
James Thompson
 
C programming(part 3)
C programming(part 3)C programming(part 3)
C programming(part 3)
Dr. SURBHI SAROHA
 
Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)
Dr. SURBHI SAROHA
 
Migrating an Application from Angular 1 to Angular 2
Migrating an Application from Angular 1 to Angular 2 Migrating an Application from Angular 1 to Angular 2
Migrating an Application from Angular 1 to Angular 2
Ross Dederer
 
Function overloading in c++
Function overloading in c++Function overloading in c++
Function overloading in c++
BalajiGovindan5
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
Mohammed Khan
 
Project two c++ tutorial
Project two c++ tutorialProject two c++ tutorial
Project two c++ tutorial
Babatunde Salaam
 
Code migration from Angular 1.x to Angular 2.0
Code migration from Angular 1.x to Angular 2.0Code migration from Angular 1.x to Angular 2.0
Code migration from Angular 1.x to Angular 2.0
Ran Wahle
 
CPP Programming Homework Help
CPP Programming Homework HelpCPP Programming Homework Help
CPP Programming Homework Help
C++ Homework Help
 
Session 5-exersice
Session 5-exersiceSession 5-exersice
Session 5-exersice
Keroles karam khalil
 
Cpp
CppCpp
Cpp
AnanthuGanesh3
 
Presentation on C language By Kirtika thakur
Presentation on C language By Kirtika thakurPresentation on C language By Kirtika thakur
Presentation on C language By Kirtika thakur
Thakurkirtika
 
Chap 4 c++
Chap 4 c++Chap 4 c++
Chap 4 c++
Venkateswarlu Vuggam
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
Dr. SURBHI SAROHA
 
csharp repitition structures
csharp repitition structurescsharp repitition structures
csharp repitition structures
Micheal Ogundero
 
escape sequences and substitution markers
escape sequences and substitution markersescape sequences and substitution markers
escape sequences and substitution markers
Micheal Ogundero
 
C++ Tail Recursion Using 64-bit variables
C++ Tail Recursion Using 64-bit variablesC++ Tail Recursion Using 64-bit variables
C++ Tail Recursion Using 64-bit variables
PVS-Studio
 
Interfaces Not Required — RubyHACK 2018
Interfaces Not Required — RubyHACK 2018Interfaces Not Required — RubyHACK 2018
Interfaces Not Required — RubyHACK 2018
James Thompson
 
Migrating an Application from Angular 1 to Angular 2
Migrating an Application from Angular 1 to Angular 2 Migrating an Application from Angular 1 to Angular 2
Migrating an Application from Angular 1 to Angular 2
Ross Dederer
 
Function overloading in c++
Function overloading in c++Function overloading in c++
Function overloading in c++
BalajiGovindan5
 
Code migration from Angular 1.x to Angular 2.0
Code migration from Angular 1.x to Angular 2.0Code migration from Angular 1.x to Angular 2.0
Code migration from Angular 1.x to Angular 2.0
Ran Wahle
 
CPP Programming Homework Help
CPP Programming Homework HelpCPP Programming Homework Help
CPP Programming Homework Help
C++ Homework Help
 
Presentation on C language By Kirtika thakur
Presentation on C language By Kirtika thakurPresentation on C language By Kirtika thakur
Presentation on C language By Kirtika thakur
Thakurkirtika
 

Viewers also liked (13)

C# features through examples
C# features through examplesC# features through examples
C# features through examples
Zayen Chagra
 
Dynamic C#
Dynamic C# Dynamic C#
Dynamic C#
Antya Dev
 
Configuring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky serversConfiguring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky servers
Axilis
 
NuGet Must Haves for LINQ
NuGet Must Haves for LINQNuGet Must Haves for LINQ
NuGet Must Haves for LINQ
Axilis
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegan
talenttransform
 
C# 6.0 - DotNetNotts
C# 6.0 - DotNetNottsC# 6.0 - DotNetNotts
C# 6.0 - DotNetNotts
citizenmatt
 
Functional Programming with C#
Functional Programming with C#Functional Programming with C#
Functional Programming with C#
EastBanc Tachnologies
 
Functional Programming in C# and F#
Functional Programming in C# and F#Functional Programming in C# and F#
Functional Programming in C# and F#
Alfonso Garcia-Caro
 
코드의 품질 (Code Quality)
코드의 품질 (Code Quality)코드의 품질 (Code Quality)
코드의 품질 (Code Quality)
ChulHui Lee
 
게임 개발에 자주 사용되는 디자인 패턴
게임 개발에 자주 사용되는 디자인 패턴게임 개발에 자주 사용되는 디자인 패턴
게임 개발에 자주 사용되는 디자인 패턴
예림 임
 
C#으로 게임 엔진 만들기(2)
C#으로 게임 엔진 만들기(2)C#으로 게임 엔진 만들기(2)
C#으로 게임 엔진 만들기(2)
지환 김
 
C#으로 게임 엔진 만들기(1)
C#으로 게임 엔진 만들기(1)C#으로 게임 엔진 만들기(1)
C#으로 게임 엔진 만들기(1)
지환 김
 
Easyloggingpp
EasyloggingppEasyloggingpp
Easyloggingpp
지환 김
 
C# features through examples
C# features through examplesC# features through examples
C# features through examples
Zayen Chagra
 
Configuring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky serversConfiguring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky servers
Axilis
 
NuGet Must Haves for LINQ
NuGet Must Haves for LINQNuGet Must Haves for LINQ
NuGet Must Haves for LINQ
Axilis
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegan
talenttransform
 
C# 6.0 - DotNetNotts
C# 6.0 - DotNetNottsC# 6.0 - DotNetNotts
C# 6.0 - DotNetNotts
citizenmatt
 
Functional Programming in C# and F#
Functional Programming in C# and F#Functional Programming in C# and F#
Functional Programming in C# and F#
Alfonso Garcia-Caro
 
코드의 품질 (Code Quality)
코드의 품질 (Code Quality)코드의 품질 (Code Quality)
코드의 품질 (Code Quality)
ChulHui Lee
 
게임 개발에 자주 사용되는 디자인 패턴
게임 개발에 자주 사용되는 디자인 패턴게임 개발에 자주 사용되는 디자인 패턴
게임 개발에 자주 사용되는 디자인 패턴
예림 임
 
C#으로 게임 엔진 만들기(2)
C#으로 게임 엔진 만들기(2)C#으로 게임 엔진 만들기(2)
C#으로 게임 엔진 만들기(2)
지환 김
 
C#으로 게임 엔진 만들기(1)
C#으로 게임 엔진 만들기(1)C#으로 게임 엔진 만들기(1)
C#으로 게임 엔진 만들기(1)
지환 김
 
Ad

Similar to New features in C# 6 (20)

Chapter3: fundamental programming
Chapter3: fundamental programmingChapter3: fundamental programming
Chapter3: fundamental programming
Ngeam Soly
 
Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
Bcsl 031 solve assignment
Indira Gnadhi National Open University (IGNOU)
 
C#/.NET Little Wonders
C#/.NET Little WondersC#/.NET Little Wonders
C#/.NET Little Wonders
BlackRabbitCoder
 
Cordovilla
CordovillaCordovilla
Cordovilla
brianmae002
 
Learn Concept of Class and Object in C# Part 3
Learn Concept of Class and Object in C#  Part 3Learn Concept of Class and Object in C#  Part 3
Learn Concept of Class and Object in C# Part 3
C# Learning Classes
 
C# 6.0
C# 6.0C# 6.0
C# 6.0
Paul Graham
 
Static code analysis and the new language standard C++0x
Static code analysis and the new language standard C++0xStatic code analysis and the new language standard C++0x
Static code analysis and the new language standard C++0x
Andrey Karpov
 
Static code analysis and the new language standard C++0x
Static code analysis and the new language standard C++0xStatic code analysis and the new language standard C++0x
Static code analysis and the new language standard C++0x
PVS-Studio
 
Overview of c#
Overview of c#Overview of c#
Overview of c#
Prasanna Kumar SM
 
A POWERPOINT PRESENTATION ABOUT INTRODUCTION TO C#
A POWERPOINT PRESENTATION ABOUT INTRODUCTION TO C#A POWERPOINT PRESENTATION ABOUT INTRODUCTION TO C#
A POWERPOINT PRESENTATION ABOUT INTRODUCTION TO C#
Jhay Deeh
 
fundamental of c++ for students of b.tech iii rd year student
fundamental of c++ for students of b.tech iii rd year studentfundamental of c++ for students of b.tech iii rd year student
fundamental of c++ for students of b.tech iii rd year student
Somesh Kumar
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project Analyzed
PVS-Studio
 
Diving into VS 2015 Day2
Diving into VS 2015 Day2Diving into VS 2015 Day2
Diving into VS 2015 Day2
Akhil Mittal
 
C# features
C# featuresC# features
C# features
sagaroceanic11
 
T2
T2T2
T2
lksoo
 
C++ LectuNSVAHDVQwyfkyuQWVHGWQUDKFEre-14.pptx
C++ LectuNSVAHDVQwyfkyuQWVHGWQUDKFEre-14.pptxC++ LectuNSVAHDVQwyfkyuQWVHGWQUDKFEre-14.pptx
C++ LectuNSVAHDVQwyfkyuQWVHGWQUDKFEre-14.pptx
ApoorvMalviya2
 
Amusing C#
Amusing C#Amusing C#
Amusing C#
PVS-Studio
 
Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1
Vahid Farahmandian
 
C# 6.0 and 7.0 new features
C# 6.0 and 7.0 new featuresC# 6.0 and 7.0 new features
C# 6.0 and 7.0 new features
Carlos Landeras Martínez
 
Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4
Rich Helton
 
Chapter3: fundamental programming
Chapter3: fundamental programmingChapter3: fundamental programming
Chapter3: fundamental programming
Ngeam Soly
 
Learn Concept of Class and Object in C# Part 3
Learn Concept of Class and Object in C#  Part 3Learn Concept of Class and Object in C#  Part 3
Learn Concept of Class and Object in C# Part 3
C# Learning Classes
 
Static code analysis and the new language standard C++0x
Static code analysis and the new language standard C++0xStatic code analysis and the new language standard C++0x
Static code analysis and the new language standard C++0x
Andrey Karpov
 
Static code analysis and the new language standard C++0x
Static code analysis and the new language standard C++0xStatic code analysis and the new language standard C++0x
Static code analysis and the new language standard C++0x
PVS-Studio
 
A POWERPOINT PRESENTATION ABOUT INTRODUCTION TO C#
A POWERPOINT PRESENTATION ABOUT INTRODUCTION TO C#A POWERPOINT PRESENTATION ABOUT INTRODUCTION TO C#
A POWERPOINT PRESENTATION ABOUT INTRODUCTION TO C#
Jhay Deeh
 
fundamental of c++ for students of b.tech iii rd year student
fundamental of c++ for students of b.tech iii rd year studentfundamental of c++ for students of b.tech iii rd year student
fundamental of c++ for students of b.tech iii rd year student
Somesh Kumar
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project Analyzed
PVS-Studio
 
Diving into VS 2015 Day2
Diving into VS 2015 Day2Diving into VS 2015 Day2
Diving into VS 2015 Day2
Akhil Mittal
 
C++ LectuNSVAHDVQwyfkyuQWVHGWQUDKFEre-14.pptx
C++ LectuNSVAHDVQwyfkyuQWVHGWQUDKFEre-14.pptxC++ LectuNSVAHDVQwyfkyuQWVHGWQUDKFEre-14.pptx
C++ LectuNSVAHDVQwyfkyuQWVHGWQUDKFEre-14.pptx
ApoorvMalviya2
 
Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1
Vahid Farahmandian
 
Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4Overview of CSharp MVC3 and EF4
Overview of CSharp MVC3 and EF4
Rich Helton
 
Ad

Recently uploaded (20)

Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 

New features in C# 6

  • 2. 01 What to expect from this slide?  Microsoft has announced some new keywords and behavior for C# 6.0 in Visual Studio 2015  The features are listed as a comparison between C# 6.0 and C# 5.0  Relevant samples are also provided to get a better understanding of the features.
  • 3. 02 What are new features ?  using Static  Auto property initializer  Dictionary Initializer  nameof Expression  New way for Exception filters  Null – Conditional Operator  Expression–Bodied Methods  Easily format strings – String interpolation
  • 4. 03 1) using static C# 6.0 allows us to use any class that is static as a namespace. This is very useful for every developer where we need to call the static methods from a static class 1) Convert.ToInt32() 2) Console.WriteLine() e.g. code in C# 5.0 Console.WriteLine(“Enter First Number : “); int num1 = Convert.ToInt32(Console.ReadLine()); How to write the same code in C# 6.0 using System.Console; using System.Convert; WriteLine(“Enter First Number : ”); int mum1 = ToInt32(ReadLine());
  • 5. 04 1) using static (cont’d) C# 5.0 Screenshot C# 6.0 Screenshot
  • 6. 05 2) Auto property initializer C# 5.0 C# 6.0 Auto property initializer is a new concept to set the value of a property during property declaration. We can set default value to a read-only property, it means a property that has only a {get;} attribute.
  • 7. 06 3) Dictionary Initializer In C# 6.0, the dictionary initialization happens in the same way but with keys as indexers which makes the code easy to read and understandable. Here is a piece of code to show you how the new initializing feature can be used. This is almost similar to how you access them e.g. errorCodes [1] = “Ex000001”. Here in C# 6.0 we can initialize the Dictionary values directly by the “=” operator and in C# 5.0 we need to create an object as a {key,value} pair and the output will be the same in both versions. Dictionary Initialization is not a new thing in C#. It was present since C# 3.0, but in C# 6.0 Microsoft enhanced this by adding a new ability to use the key/indexer to map with the dictionary values directly during the initialization itself. The following code snippet shows how dictionary initializer were used prior to C# 6.0 to initialize dictionary objects with key and values. This is still valid and you can use it as earlier.
  • 8. 07 3) Dictionary Initializer (cont’d) C# 6C# 5
  • 9. 08 4) nameof - Expression nameof expression will return a string literal of the name of a property or a method.
  • 10. 09 5) Exception filters Exception filters allow us to specify a condition with a catch block. So the catch block is executed only if the condition is satisfied.
  • 11. 10 6) Null-Conditional Operator Suppose we need to write a code to compare the objects of an employee class with null-conditional operator in C# 5.0, we will need to write multiple lines of code using if() and else. In C# 6.0, we can rewrite the same code using ? and ?? . The following sample code shows how to check the null value of an object in C# 6.0
  • 12. 11 7) Expression–Bodied Methods C#5.0 C#6.0 An Expression–Bodied Method is a very useful way to write a function in a new way. By using the “=>“ lamda Operator in C# 6.0, we can easily write methods with single line.
  • 13. 12 8) Easily format strings using String interpolation To easily format a string value in C# 6.0 without any string.Format() method we can write a format for a string. It's a very useful and time saving process to define multiple string values by $“{ variable }”.
  • 14. 13 SOFTWARE ASSOCIATES Software Associates “Mascot”, Zilla Bungalow Road, Nadakkavu, Kozhikode PIN 673011, Kerala, India Kozhikode +91 495 276 5837 | Bangalore +91 984 700 5656 | London +44 797 340 0804 REACH OUT TO US