| What are the new feature of C# 11 that is coming?
C# 10 is recently released and C# 11 is in progress. There are many new features are included in this version of C#. Below are the list of new features of C#:-
(1)New List Pattern
New feature of List Pattern which allows us to do comparison between List Pattern and array or List. Here you will able to match different elements or even a cut pattern to match 0 or more elements. To understand this we we will take example as given below:-
Pattern [1, 2, .., 10] matches all below example:-
And to explore list pattern we consider below example:-
When it is passed the following arrays the results are as indicated at end of line:-
(2)Parameter Null Checking
This is basically handle null and to validate if the method argument are null. Below example will more clarify:-
(i)In old code we use below parameter
(ii)And now we can use below abbreviation for treating null values
(iii)Below example of checking indexer parameter with set and get
(3)Constructors
Change in null-checks using the null validation syntax (!!). And explicit validation occurs after field initializers, base class constructors, and constructors called using this.
(4)Interaction with Nullable Reference Types
!! operator we have seen before, it will start as non-null with a nullable state. BElow example will clarify you more:-
| | |