Desc: C#9 is set to release in November 2020 which will be a significant upgrade to the company’s type-safe, object-oriented language. Know everything about C#9 and its features.
C# Developed by a team around Anders Hejlsberg, also known for his work on Turbo Pascal, and Delphi, as part of Microsoft's .NET initiative almost 20 years ago. Simple, modern, mature and suitable for applications, C# is one of the most trusted programming languages.
C# 9.0 is finally coming together in the right place. With every new version of C# the focus is on greater clarity and ease in coding scenarios that will simplify the lives of C# developers and streamline the development process. This proposed new C# 9.0 is no exception. If you want to know more about C# and its advantages in building applications, it is important to get in touch with C# software development company.
At Microsoft Build 2020, Mads Torgersen, Program Manager for the C# Language showed C# 9.0 features that will be shipped with .NET 5 in upcoming November 2020.
The status of each feature for the new version with quick details about availability in Visual Studio previews is available at Github C# repository.
Don't get misled by the milestone view of the project which runs to a due date almost decades away.
The new version of C# development is slated to release in November 2020 as mentioned in Microsoft Build.
What's coming in C# 9
Init-only properties, object initializers to the client of a type are extremely flexible and readable format to build an object, and they are especially great for nested object creation where a whole tree of objects is created in one go.
Object initializers are developer's delight and free the type author from writing hassles of complexity. After all, that is required is to write simple properties!
One of the key features of C#9 would be records. Init-only properties can work wonders for individual properties immutable and behave like a value, then declaring it as a record. Records are "values" and not mere objects.
They depict change by creating new records which signify new state and are defined not by identity, but by their contents.
Immutable, with init-only public properties, Records can be non-destructively modified through with-expressions. Records often change the defaults to optimize for that common case.
It makes up for explicit record declarations.
It makes for beautiful and clear record declarations. In case the requirement is of a single field, you can just clearly add the private modifier.
not Keywords for the pattern which afford more flexibility and robustness with conjunctive, disjunctive, and negated patterns
If you want to minimize confusion in the operators used in expressions, logical operators such as "and, or and not" should be spelled out.
Declaration form for C# class and struct types which amalgamates benefits of same features with a way to declare a datatype by describing members of the aggregate as well as extra code or deviations from boilerplate, if any.
Type Inference for the New Keyword
new expression proposal has been adopted into C# 9; such boilerplate code will no longer be necessary.
Improved target typing
When the expression gets its type from the context of where it is being used, Target typing comes in place. Typical examples would be null and lambda which are target typed.
When it comes to C#, expressions not previously target typed can now be guided by their context.
It is useful to express that a method override in a derived class has a more specific return type than the declaration in the base type.
When it comes to C#, even writing a simple program can be an arduous task with too much of boilerplate code.
This adds to the level of code and ultimately clutter in the code. But this problem is all set to get resolved. With C#9, it is relatively simple to write the main program at the top level.
Local functions are typically a form of statement and allowed in top-level program. It is an error to call from anywhere outside of the top-level statement section.
Improved pattern matching
Several different kinds of patterns have been incorporated in C# 9.0. Let's look at the context of code snippet.
Simple type patterns: a type pattern needs to declare an identifier when the type matches
Relational patterns: patterns corresponding to the relational operators <, <=
Logical patterns: combine patterns with logical operators and, or and not, spelt out as words to avoid confusion with the operators used in expressions.
Microsoft C# 9.0 will be a significant upgrade to the company’s type-safe, object-oriented language that will incorporate new capabilities right from records to value-based equality and more.
However, it is important to note that several proposed features and syntax/semantics might change. On the other hand, there is also a possibility that few features might be changed or removed altogether. Only .NET developers can decide which features will be released in C# 9 and when it will be released.
Do follow this blog space to know the features of C#9 upon release.
CTA: Want to leverage the benefits of C# Development? Get in touch with our team