All rules
IDE0090Expression-level preferences MS default: Suggestion

Simplify new expression

Use target-typed `new()` when the type is apparent.

Microsoft docs

Description

Prefers new() over new TypeName() when the type can be inferred from the declaration context.

Why it matters

Target-typed new reduces repetition of long type names without losing type safety.

Examples

Avoid
private Dictionary<string, int> _map = new Dictionary<string, int>();
Prefer
private Dictionary<string, int> _map = new();

Configurable options

Vote for the value each option should take in the generated .editorconfig.

csharp_style_implicit_object_creation_when_type_is_apparent
default: true
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0