C# 9 and F# 5 Released With .NET 5 – iProgrammer

Microsoft has released C#9 and F#5 as part of the .NET5 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.

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 doesnt 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 its being used for and produces its name in F# source.

Both languages are part of the .NET SDK.

NET 5 SDK

.NET 5 Ready For Action

To be informed about new articles on IProgrammer,sign up for ourweekly newsletter,subscribe to theRSSfeedandfollow us on,Twitter,Facebook orLinkedin.

Make a Comment or View Existing Comments Using Disqus

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

See the original post here:
C# 9 and F# 5 Released With .NET 5 - iProgrammer

Related Posts
This entry was posted in $1$s. Bookmark the permalink.