Introducing C# 10: Extended property patterns


C# 8 has introduced a new pattern: Property pattern. This pattern enables you to match on properties of the object examined, if you missed that feature, here is the Microsoft documentation here: Property pattern. C# 10 improves that pattern by simplifying access to nested properties. In the article I’ll show what it is.


The following code sample shows a C# 8 tax calculator, which involves an object named CalculateTax and its nested property named ProvinceOrStateTaxProperty which is itself an object:

The syntax to access the nested property is a bit verbose:

{ ProvinceTaxProperty: { ProvinceOrState: "Value" } }

C# 10 fixes that and allows to access directly the nested property by a dot:

Much more practical isn’t it ? 😉

Written by


Anthony is a specialist in Web technologies (14 years of experience), in particular Microsoft .NET and learns the Cloud Azure platform. He has received twice the Microsoft MVP award and he is also certified Microsoft MCSD and Azure Fundamentals.
%d bloggers like this: