Skip to content

C# Feature - Target-typed new

Target-typed new removes duplicated type names from object creation when the target type is already known.

C# 9.0 (2020)

Dictionary<string, int> counts = new Dictionary<string, int>();
Dictionary<string, int> counts = new();
  • Use it only when the target type is obvious from context.
  • Prefer explicit construction when brevity hurts readability.