This article outlines the new features that have been added to the new C# version 6.0.
This article outlines the new features that have been added to the new C# version 6.0. The new and enhanced features are:
Enhancement to Auto Properties: Currently auto properties are needed to have setters. This makes a disadvantage for immutable data types. Now C# 6 allows only getters on auto properties. C# 6 also allows initializers to auto properties as shown in the following picture:Using Static classes: Now you can put static members directly into the scope without using their class names as in the following:String interpolation: Existing string.format function:With the new syntax you can define the escape characters inside { } .Expression-bodied methods: You can use a lambda arrow to just implement the single expression. Often it looks like this:But now we can re-write the preceding in a single line as in the following:Index initializers: Today you can initialize properties in object initializers as in the following:But indexers still need to be assigned in separate statements. Now you can initialize indexes inside object initializers as shown below.Null Conditional Operators: Today we do null condition checking for indexers as in the following:In C# 6 , there is no explicit null check using the ? . Operator. The new way of writing the preceding is as in the following:It works like, if the left hand side is null, the entire thing is null. Only when it is not null it does the dot(.) then it becomes as result of the operation. Delegate null checking can be written as follows:
FileInfo in C#