target-typed new

Writing new() without a type name where the type is already known from the left-hand side, as in Dictionary<string, decimal> prices = new();.

In more detail

It also works for fields, parameters and return values whose type is already declared. It removes repetition without hiding the type, since the declaration still names it.

Related terms

Taught in

References