Professional Documents
Culture Documents
N TO .NET 5 &
C# 9.0
FEATURES
Internal Use - Confidential
HISTORY
The birth of the project
Microsoft technical team met as a in December 2018 in Boston to kick off this project. Design leaders
from .NET teams (Mono/Xamarin and .NET Core) and also from Unity presented on various technical
capabilities and architectural direction.
We are now moving forward on this project as a single team with one set of deliverables. Since December, we
have made a lot of progress on a few projects:
Defined a minimal layer that defines the runtime <-> managed code layer, with the goal making >99% of
CoreFX common code. MonoVM can now use CoreFX and its class libraries. Run all CoreFX tests on
MonoVM using the CoreFX implementation. Run ASP.NET Core 3.0 apps with MonoVM. Run
MonoDevelop and then Visual Studio for Mac on CoreCLR.
C# 9.0
Records
Init-only properties
Top-level statements
Pattern matching enhancements
Fit and finish features
Implement System.IEquatable<T>
Reference types
Immutable by default (none of the properties can be modified once it's been created)
e.g. –
public record Person
{
public string LastName { get; }
public string FirstName { get; }
public Person(string first, string last) => (FirstName, LastName) = (first, last);
}
Supports inheritance
Seal records to prevent further derivation
Support copy construction
Records can be copied with modification. These copy and modify operations supports non-destructive mutation
Supports with expression (creates n copies by deriving with expression)
Value based equality.
public static bool IsLetter(this char c) => c is >= 'a' and <= 'z' or >= 'A' and <= 'Z';
can omit the type in a new expression when the created object's type is already known
- private List<WeatherObservation> _observations = new();
Target-typed new can also be used when you need to create a new object to pass as an argument to a method
improves the target type resolution of conditional expressions, to overcome on problem of conditional ?? and ?:
expressions don’t have an obvious shared type between the branches
apply attributes to local functions
Covariant returns - to express that a method override in a derived class has a more specific return type than the
declaration in the base type
new syntax for a null/not null check
if(obj is null) // null check
if(obj is not null) // not null check