C# 12: The Features That Are Turning Heads

CSharp Features, .NET, Microsoft

Alex Maher
5 min readOct 5, 2023

C# 12, introduced in the latest Visual Studio previews and .NET 8 preview SDK it’s making waves in the developer community.

C# keeps getting better with each version, and this one’s no exception.

It’s packed with new tools that make our coding life easier and more fun. If you’re a C# fan like me, you’re going to love exploring all the new stuff.

Let’s jump in and see what it’s all about!

Primary Constructors

Primary constructors are a game-changer for object initialization. Instead of declaring properties and then a constructor separately, developers can now do both simultaneously.

public class Person(string name, int age)
{
public string Name { get; } = name;
public int Age { get; } = age;
}

This feature shines especially for classes intended to be immutable. It reduces boilerplate code, making the codebase cleaner and more readable. For developers, this means faster coding with fewer errors.

Optional Parameters in Lambda Expressions

Lambda expressions have always been a powerful tool in C#. With the introduction of optional parameters, their…

--

--

Alex Maher

.NET C# dev with 10+ yrs exp, self-taught & passionate web developer. Sharing tips & experiences in C# and web dev.