C# 12 simplifies code with collection expressions, primary constructors for all classes and structs, syntax to alias any type, and default parameters for lambda expressions. Credit: PeopleImages / Getty Images C# 12, the latest edition of Microsoft’s popular object-oriented programming language, is now available as a production release, offering a simplified syntax and faster program execution. C# 12 was unveiled as part of the .NET 8 software development platform on November 14. Developers can access it by downloading .NET 8, the Visual Studio 2022, or the Visual Studio Code C# Dev Kit extension. To simplify code, C# 12 introduces collection expressions, primary constructors for all classes and structs, syntax to alias any type, and default parameters for lambda expressions. Collection expressions introduce a new terse syntax to create common collection values. Microsoft in noting these capabilities stressed it has set a goal for new features to not degrade performance. To make code execution faster, C# 12 adds ref readonly parameters and inline arrays. Adding ref readonly parameters provides a final combination of passing parameters by reference or by value. An argument to a ref readonly parameter must be a variable. Inline arrays, which are a struct-based, fixed-length array type, provide a safe way to work with memory buffers. Interceptors, an experimental feature available in preview, allow redirection of method calls. C# also features an experimental attribute, SystemDiagnostics.CodeAnalysis.ExperimentalAttribute, that makes it clear when Microsoft is not yet committed to a feature or implementation. When code uses types or members that are experimental, an error will occur unless the calling code is also marked as experimental. Each use of ExperimentalAttribute has a diagnostic ID for suppressing the error for individual features by an explicit compiler option or #pragma so developers can explore the experimental feature. Types, members, and assemblies can be marked with ExperimentalAttribute. C# 12 ranks fifth in the Tiobe index of programming language popularity this month, ahead of languages such as JavaScript and PHP. Preceding C# 12 was C# 11, released in November 2022, featuring string literals and generic math. Related content analysis Beyond the usual suspects: 5 fresh data science tools to try today The mid-month report includes quick tips for easier Python installation, a new VS Code-like IDE just for Python and R users, and five newer data science tools you won't want to miss. By Serdar Yegulalp Jul 12, 2024 2 mins Python Programming Languages Software Development analysis Generative AI won’t fix cloud migration You’ve probably heard how generative AI will solve all cloud migration problems. It’s not that simple. Generative AI could actually make it harder and more costly. By David Linthicum Jul 12, 2024 5 mins Generative AI Artificial Intelligence Cloud Computing news HR professionals trust AI recommendations HireVue survey finds 73% of HR professionals trust AI to make candidate recommendations, while 75% of workers are opposed to AI making hiring decisions. By Paul Krill Jul 11, 2024 3 mins Technology Industry Careers how-to Safety off: Programming in Rust with `unsafe` What does it mean to write unsafe code in Rust, and what can you do (and not do) with the 'unsafe' keyword? The facts may surprise you. By Serdar Yegulalp Jul 11, 2024 8 mins Rust Programming Languages Software Development Resources Videos