C# 9 and F# 5 Released With .NET 5
Written by Kay Ewbank   
Thursday, 12 November 2020

Microsoft has released C# 9 and F# 5 as part of the .NET 5 release this week. Visual Basic is also included in the 5.0 SDK. It does not include language changes, but has improvements to support the Visual Basic Application Framework on .NET Core.

The improvements to C# 9 are aimed at improving program simplicity, along with support for data-oriented classes. F# 5 adds support for interpolated strings and open type declarations.

c

The developers say that C# source generators are an important new C# compiler feature, though they are not technically part of C# 9 since it doesn’t have any language syntax. Syntax generators are a new C# compiler feature that means C# developers can inspect user code and generate new C# source files that can be added to a compilation. This is done via a new kind of component  The .NET team expects to make more use of source generators within the .NET product in .NET 6.0 and beyond.

C# 9 also adds support for new patterns, including simple type patterns that avoid the need to declare an identifier when the type matches, and relational patterns that correspond to the relational operators <, <= and so on. Support has also been added for logical patterns meaning you can combine patterns with logical operators and, or and not, spelled out as words to avoid confusion with the operators used in expressions.

Another addition to C# 9 is support for a record class.The development team says that while C# has always worked well for classic object-oriented programming where an object has strong identity and encapsulates mutable state, having records is useful if you find yourself wanting the whole object to be immutable and behave like a value. A record is still a class, but the record keyword imbues it with several additional value-like behaviors. Generally speaking, records are defined by their contents, not their identity.

F# has also been updated in the new release. The F# team says that F# 5 marks the start of a new era of F# evolution centered around interactive programming. More practically, the new release adds support for package references in F# scripts with #r "nuget:..." syntax, along with support for Jupyter, nteract, and VSCode notebooks.

String Interpolation has also finally been added to F#. The team says F# interpolated strings are fairly similar to C# or JavaScript interpolated strings, in that they let you write code in “holes” inside of a string literal. They also allow for typed interpolations, just like the sprintf function, to enforce that an expression inside of an interpolated context conforms to a particular type. Another highly-requested feature of F# 5 is nameof which resolves the symbol it’s being used for and produces its name in F# source.

Both languages are part of the .NET SDK.

c

More Information

NET 5 SDK

Related Articles

.NET 5 Ready For Action

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


pgxman - PostgreSQL Extension Manager
19/02/2024

pgxman is a package manager like npm, but instead of Javascript packages, it is for PostgreSQL extensions. It detects and streamlines extension operations and looks after dependency manageme [ ... ]



Couchbase Adds Vector Search
07/03/2024

Couchbase is adding support for vector search across its entire product line including Capella, Enterprise Server, and Mobile. Support has also been added for retrieval-augmented generation (RAG) tech [ ... ]


More News

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Thursday, 12 November 2020 )