Microsoft unveils C# 12 language enhancements

InfoWorld | at | by Mike

Microsoft, with the latest preview of its planned .NET 8 software development platform, is highlighting three new C# 12 language features: primary constructors for non-record classes and structs, the use of aliases for any type, and default values for lambda expression parameters.These capabilities are included in .NET 8 Preview 3, which was released April 11. General availability of both C# 12 and .NET 8 is expected in November. Developers also can access the C# 12 features in the latest Visual Studio 17.6 preview.With primary constructors, developers can add parameters to the class declaration itself and use these values in the class body. For example, developers could use the parameters to initialize properties or use the parameters in the code of methods and property accessors. Primary constructors were introduced for records in C# 9 as part of the positional syntax for records. C# 12 extends these to all structs and classes.