SlideShare una empresa de Scribd logo
1 de 8
What is new in C Sharp 6.0 ?
We will discuss what is new in C Sharp 6.0 that is bringing more attention towards the
programming communities.
In this article, I’ll display the new components and give a report about the new features
that are attracting the C# developers around the world.
Redefining the null conditional operator “?”
Indeed, even the most up to date .NET engineers are likely acquainted with the
NullReferenceException. This is an exemption that quite often shows a bug in light of
the fact that the engineer didn’t perform adequate null value checking before calling a
member on an object that has (null) value.
The null propagation operator
C# 6.0 presented numerous new elements in Visual Studio 2015 Review. How about we
observe one of its new elements, the null propagation operator. In prior adaptations of
the C# dialect(language), we generally needed to compose an if condition for an invalid
check before utilizing an object or its properties. Presently C# 6.0 has presented the
Null-Propagation Operator (?.) that empowers engineers to check for the null inside of
an object references. The null-propagation operator (?.) will return null if anything in the
object references is null. We require a superior method for taking care of null exception
cases where propagation of null exists. The operator can now be utilized like “nullable
types” by simply using a question mark (?) after the method instance before calling the
property. We don’t have to compose extra if statements to check for the nulls.
Examples
The Old-School approach for using multiple if else checks:
using System;
namespace Csharp6NullPropagation
{
class Employees
{
static void Main()
{
Employee employee1 = new Employee();
employee1.Name = “Adeel Ahmed”;
employee1.ID = 23;
employee1.contacts = new Contact()
{ Address = “ABC Street House XYZ”, Email = “123@afd.com” };
Employee employee2 = new Employee();
employee2.Name = “William Smith “;
employee2.ID = 52;
employee2.contacts = new Contact() { Address = null, Email = null };
Console.WriteLine(“Employee 1:n”);
if (employee1.Name == null) Console.WriteLine(“No Name Provided”);
else Console.WriteLine(employee1.Name);
if (employee1.contacts.Address == null) Console.WriteLine(” No Address Provided”);
else Console.WriteLine(employee1.contacts.Address);
Console.WriteLine(“nEmployee 2:n”);
if (employee2.Name == null) Console.WriteLine(“No Name Provided”);
else Console.WriteLine(employee2.Name);
if (employee2.contacts.Email == null) Console.WriteLine(“No Email Provided”);
else Console.WriteLine(employee2.contacts.Email);
if (employee2.ID == null) Console.WriteLine(“No ID Provided”);
else Console.WriteLine(employee2.ID);
Console.ReadLine();
}
}
class Employee
{
public string Name { get; set; }
public int ID { get; set; }
public Contact { get; set; }
}
class Contact contacts
{
public string Address { get; set; }
public string Email { get; set; }
}
}
Now, the null propagation operator in C# 6.0 makes the developer’s life much easier.
Trendy use of null propagation operator
using System;
namespace Csharp6NullPropagation
{
class Employees
{
static void Main()
{
Employee employee1 = new Employee();
employee1.Name = “Adeel Ahmed”;
employee1.ID = 23;
employee1.contacts= new Contact()
{ Address = “ABC Street House XYZ “, Email = “123d@afd.com” };
Employee employee2 = new Employee();
employee2.Name = “William Smith”;
employee2.ID = 52;
employee2.contacts = new Contact()
{ Address = null, Email = null };
WriteLine(“Employee 1:n”);
WriteLine(employee1?.Name ?? “No Name”);
WriteLine(employee1?.contacts?.Address ?? “No Address”);
WriteLine(employee1?.contacts?.Email ?? “No Email provided”);
WriteLine(“nStudent 2:n”);
WriteLine(employee2?.Name ?? “No Name”);
WriteLine(employee2?.contacts?.Address ?? “No Address”);
WriteLine(employee2?.contacts?.Email ?? “No Email provided”);
ReadLine();
}
}
class Employee
{
public string Name { get; set; }
public int ID { get; set; }
public Contact contacts { get; set; }
}
class Contact contacts
{
public string Address { get; set; }
public string Email { get; set; }
}
}
More new features in
CSharp 6
SyedAdeel Ahmed / 5 days ago
Image credit: kumarvikram.com
More new features in CSharp 6
The more new features in CSharp 6 will be available in Visual Studio 2015. There are
many exiting new features, that help in both the development and the productivity of the
software . Some main features include:
Initializers for properties
You can now add an initializer to an auto-property, pretty much as you can in a field:
public class DataCollected
{
public bool Married {get; set}=true;
public int Age { get; set; } = 25;
public float salary { get; set; } = 60000.12;
}
The initializer straightforwardly instates the field; it doesn’t work through the setter of the
property. The initializers are executed all together as composed, pretty much as; and
alongside with field initializers.
Much the same as field initializers, auto-property initializers can’t reference this – after
all they are executed before the object is legitimately initialized
Auto-properties concept
Properties can now be announced without a setter.
public class CarData
{
public int TotalCars { get; } = 20;
public string CarPrice { get; } = “2000$” ;
}
The support field of a getter-only auto-property is certainly pronounced as “readonly” . It
can be introduced through an initializer on the property as in the illustration above.
Additionally, a getter property can be assigned to a constructor also:
public class Myname
{
public string Name { get; }
public Myname(string fname, string lname)
{
Name = fname + ” + lname;
}
}
Have you seen this before previously? Surely not!
Methods and also user-characterized operators and transformations can be given an
expression body by utilization of the “lambda sign”. For example:
public Coordinates AddValues(int x1, int y1) => new Coordinates(x2 + x, y2 + y);
public class Person
{
public Person(float expenditures, float profits)
{
Expenditure = expenditures;
Profit = profits;
}
public float Expenditure { get; protected set; }
public float Profit { get; set; }
public void ProfitIncrease() => Profit++;
public float Expenditures() =>Profit- Expenditure;
}
Static members references
This feature permits all the available static members to be imported directly
in using statement when referring to the built in classes(for example).
using static System.Console;
using static System.Math;
using static System.DayOfWeek;
class System
{
static void Main()
{
WriteLine(Sqrt(9*9 + 2*2));
WriteLine(Saturday-Wednesday);
}
}
This is awesome feature introduced in C# 6.0

Más contenido relacionado

Destacado

Rachel Rodriguez – Best practices for working with eyewitness media on social...
Rachel Rodriguez – Best practices for working with eyewitness media on social...Rachel Rodriguez – Best practices for working with eyewitness media on social...
Rachel Rodriguez – Best practices for working with eyewitness media on social...Journalism.co.uk
 
0531 981 01 90 SALACAK KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 053...
0531 981 01 90 SALACAK KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 053...0531 981 01 90 SALACAK KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 053...
0531 981 01 90 SALACAK KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 053...Antika Alanlar
 
0531-981-01-90 VE 0532-335-75-06 İKİNCİ EL KİTAP ALANLAR KADIRGADA KİTAP ALA...
0531-981-01-90 VE  0532-335-75-06 İKİNCİ EL KİTAP ALANLAR KADIRGADA KİTAP ALA...0531-981-01-90 VE  0532-335-75-06 İKİNCİ EL KİTAP ALANLAR KADIRGADA KİTAP ALA...
0531-981-01-90 VE 0532-335-75-06 İKİNCİ EL KİTAP ALANLAR KADIRGADA KİTAP ALA...antika alanlar
 
0531 981 01 90 DİKİLİTAŞ KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 0...
0531 981 01 90 DİKİLİTAŞ KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 0...0531 981 01 90 DİKİLİTAŞ KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 0...
0531 981 01 90 DİKİLİTAŞ KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 0...Antika Alanlar
 
Photo Essay - Pope Up Arts
Photo Essay - Pope Up ArtsPhoto Essay - Pope Up Arts
Photo Essay - Pope Up Artsashaundeismith
 
시부랄필름
시부랄필름시부랄필름
시부랄필름sangil han
 

Destacado (9)

Rachel Rodriguez – Best practices for working with eyewitness media on social...
Rachel Rodriguez – Best practices for working with eyewitness media on social...Rachel Rodriguez – Best practices for working with eyewitness media on social...
Rachel Rodriguez – Best practices for working with eyewitness media on social...
 
0531 981 01 90 SALACAK KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 053...
0531 981 01 90 SALACAK KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 053...0531 981 01 90 SALACAK KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 053...
0531 981 01 90 SALACAK KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 053...
 
0531-981-01-90 VE 0532-335-75-06 İKİNCİ EL KİTAP ALANLAR KADIRGADA KİTAP ALA...
0531-981-01-90 VE  0532-335-75-06 İKİNCİ EL KİTAP ALANLAR KADIRGADA KİTAP ALA...0531-981-01-90 VE  0532-335-75-06 İKİNCİ EL KİTAP ALANLAR KADIRGADA KİTAP ALA...
0531-981-01-90 VE 0532-335-75-06 İKİNCİ EL KİTAP ALANLAR KADIRGADA KİTAP ALA...
 
0531 981 01 90 DİKİLİTAŞ KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 0...
0531 981 01 90 DİKİLİTAŞ KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 0...0531 981 01 90 DİKİLİTAŞ KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 0...
0531 981 01 90 DİKİLİTAŞ KİTAP ALANLAR-PLAK-KİTAP-ANTİKA EŞYA SATIN ALANLAR 0...
 
Photo Essay - Pope Up Arts
Photo Essay - Pope Up ArtsPhoto Essay - Pope Up Arts
Photo Essay - Pope Up Arts
 
Marjatta Rahkio / Landskapsreformen
Marjatta Rahkio / LandskapsreformenMarjatta Rahkio / Landskapsreformen
Marjatta Rahkio / Landskapsreformen
 
Juha Niemelä / Landskapsreformen
Juha Niemelä / LandskapsreformenJuha Niemelä / Landskapsreformen
Juha Niemelä / Landskapsreformen
 
시부랄필름
시부랄필름시부랄필름
시부랄필름
 
CII Communique, January 2017
CII Communique, January 2017CII Communique, January 2017
CII Communique, January 2017
 

Más de AA Coaching Academy

Más de AA Coaching Academy (8)

Indexers in C#
Indexers in C#Indexers in C#
Indexers in C#
 
New rich text document
New rich text documentNew rich text document
New rich text document
 
Programming in c plus plus4
Programming in c plus plus4Programming in c plus plus4
Programming in c plus plus4
 
Programming in c plus plus3
Programming in c plus plus3Programming in c plus plus3
Programming in c plus plus3
 
Programming in c plus plus2
Programming in c plus plus2Programming in c plus plus2
Programming in c plus plus2
 
Advanced interview questions
Advanced interview questionsAdvanced interview questions
Advanced interview questions
 
Programming interview questions
Programming interview questionsProgramming interview questions
Programming interview questions
 
Professional erd models
Professional erd modelsProfessional erd models
Professional erd models
 

Último

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Último (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

What is new in c sharp 6

  • 1. What is new in C Sharp 6.0 ? We will discuss what is new in C Sharp 6.0 that is bringing more attention towards the programming communities. In this article, I’ll display the new components and give a report about the new features that are attracting the C# developers around the world. Redefining the null conditional operator “?” Indeed, even the most up to date .NET engineers are likely acquainted with the NullReferenceException. This is an exemption that quite often shows a bug in light of the fact that the engineer didn’t perform adequate null value checking before calling a member on an object that has (null) value. The null propagation operator C# 6.0 presented numerous new elements in Visual Studio 2015 Review. How about we observe one of its new elements, the null propagation operator. In prior adaptations of the C# dialect(language), we generally needed to compose an if condition for an invalid check before utilizing an object or its properties. Presently C# 6.0 has presented the Null-Propagation Operator (?.) that empowers engineers to check for the null inside of an object references. The null-propagation operator (?.) will return null if anything in the object references is null. We require a superior method for taking care of null exception cases where propagation of null exists. The operator can now be utilized like “nullable types” by simply using a question mark (?) after the method instance before calling the property. We don’t have to compose extra if statements to check for the nulls. Examples The Old-School approach for using multiple if else checks: using System; namespace Csharp6NullPropagation { class Employees { static void Main() { Employee employee1 = new Employee(); employee1.Name = “Adeel Ahmed”; employee1.ID = 23; employee1.contacts = new Contact() { Address = “ABC Street House XYZ”, Email = “123@afd.com” }; Employee employee2 = new Employee(); employee2.Name = “William Smith “;
  • 2. employee2.ID = 52; employee2.contacts = new Contact() { Address = null, Email = null }; Console.WriteLine(“Employee 1:n”); if (employee1.Name == null) Console.WriteLine(“No Name Provided”); else Console.WriteLine(employee1.Name); if (employee1.contacts.Address == null) Console.WriteLine(” No Address Provided”); else Console.WriteLine(employee1.contacts.Address); Console.WriteLine(“nEmployee 2:n”); if (employee2.Name == null) Console.WriteLine(“No Name Provided”); else Console.WriteLine(employee2.Name); if (employee2.contacts.Email == null) Console.WriteLine(“No Email Provided”); else Console.WriteLine(employee2.contacts.Email); if (employee2.ID == null) Console.WriteLine(“No ID Provided”); else Console.WriteLine(employee2.ID); Console.ReadLine(); } } class Employee { public string Name { get; set; } public int ID { get; set; } public Contact { get; set; } } class Contact contacts { public string Address { get; set; } public string Email { get; set; } } }
  • 3. Now, the null propagation operator in C# 6.0 makes the developer’s life much easier. Trendy use of null propagation operator using System; namespace Csharp6NullPropagation { class Employees { static void Main() { Employee employee1 = new Employee(); employee1.Name = “Adeel Ahmed”; employee1.ID = 23; employee1.contacts= new Contact() { Address = “ABC Street House XYZ “, Email = “123d@afd.com” }; Employee employee2 = new Employee(); employee2.Name = “William Smith”; employee2.ID = 52; employee2.contacts = new Contact() { Address = null, Email = null }; WriteLine(“Employee 1:n”); WriteLine(employee1?.Name ?? “No Name”); WriteLine(employee1?.contacts?.Address ?? “No Address”); WriteLine(employee1?.contacts?.Email ?? “No Email provided”); WriteLine(“nStudent 2:n”); WriteLine(employee2?.Name ?? “No Name”); WriteLine(employee2?.contacts?.Address ?? “No Address”); WriteLine(employee2?.contacts?.Email ?? “No Email provided”); ReadLine(); } } class Employee { public string Name { get; set; } public int ID { get; set; } public Contact contacts { get; set; } } class Contact contacts {
  • 4. public string Address { get; set; } public string Email { get; set; } } } More new features in CSharp 6 SyedAdeel Ahmed / 5 days ago
  • 5. Image credit: kumarvikram.com More new features in CSharp 6
  • 6. The more new features in CSharp 6 will be available in Visual Studio 2015. There are many exiting new features, that help in both the development and the productivity of the software . Some main features include: Initializers for properties You can now add an initializer to an auto-property, pretty much as you can in a field: public class DataCollected { public bool Married {get; set}=true; public int Age { get; set; } = 25; public float salary { get; set; } = 60000.12; } The initializer straightforwardly instates the field; it doesn’t work through the setter of the property. The initializers are executed all together as composed, pretty much as; and alongside with field initializers. Much the same as field initializers, auto-property initializers can’t reference this – after all they are executed before the object is legitimately initialized Auto-properties concept Properties can now be announced without a setter. public class CarData { public int TotalCars { get; } = 20; public string CarPrice { get; } = “2000$” ; }
  • 7. The support field of a getter-only auto-property is certainly pronounced as “readonly” . It can be introduced through an initializer on the property as in the illustration above. Additionally, a getter property can be assigned to a constructor also: public class Myname { public string Name { get; } public Myname(string fname, string lname) { Name = fname + ” + lname; } } Have you seen this before previously? Surely not! Methods and also user-characterized operators and transformations can be given an expression body by utilization of the “lambda sign”. For example: public Coordinates AddValues(int x1, int y1) => new Coordinates(x2 + x, y2 + y); public class Person { public Person(float expenditures, float profits) { Expenditure = expenditures; Profit = profits; } public float Expenditure { get; protected set; } public float Profit { get; set; }
  • 8. public void ProfitIncrease() => Profit++; public float Expenditures() =>Profit- Expenditure; } Static members references This feature permits all the available static members to be imported directly in using statement when referring to the built in classes(for example). using static System.Console; using static System.Math; using static System.DayOfWeek; class System { static void Main() { WriteLine(Sqrt(9*9 + 2*2)); WriteLine(Saturday-Wednesday); } } This is awesome feature introduced in C# 6.0